Thursday, August 22, 2019

Django - Field 'name' doesn't have a default value


When running django migration you run into following error - 

> python manage.py migrate

.........
  File "/usr/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute

    self.errorhandler(self, exc, value)
  File "/usr/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue

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



It's due to django_content_type table, where name column property is not allowing to get the migration run completing successfully as the column constraint is causing the failure.

Running following sql command would solve the issue -


ALTER TABLE django_content_type MODIFY COLUMN name character varying(50) NOT NULL DEFAULT 'not null';

No comments:

Post a Comment