[Django]-Django migrate: django.db.utils.OperationalError: (1364, "Field 'name' doesn't have a default value")

4👍

MySQL in latest versions has made it mandatory to add default value for NOT NULL columns. It is caused due to STRICT_TRANS_TABLES mode. There are 3 ways to fix it,

1) Add default value to not null columns.

    ALTER TABLE tablename MODIFY columname DATATYPE NOT NULL DEFAULT 'a value'

2) Set NULL values by default

    ALTER TABLE tablename MODIFY columname DATATYPE NULL

3) In MySQL configuration file, remove STRICT_TRANS_TABLES from sql_mode and restart the service.

0👍

I did not need table. I deleted table then ran migrations and migrate again

👤Darwin

Leave a comment