django admin error - Unknown column 'django_content_type.name' in 'field list'

The fix in MySQL for us was to drop table django_content_type;

The notes from karthikr and moonchel led me to the fix. 1054 Unknown column errors were occurring after installing Django 1.8 into one virtualenv to try it out, and then trying to use the pre-existing Django 1.6 in a different virtualenv. MySQL got messed up.

Django 1.7/1.8 syncdb revised the django_content_type table removing the 'name' column from it.

+-----------+--------------+------+-----+---------+----------------+
| Field     | Type         | Null | Key | Default | Extra          |
+-----------+--------------+------+-----+---------+----------------+
| id        | int(11)      | NO   | PRI | NULL    | auto_increment |
| app_label | varchar(100) | NO   | MUL | NULL    |                |
| model     | varchar(100) | NO   |     | NULL    |                |
+-----------+--------------+------+-----+---------+----------------+

Django 1.6 syncdb creates the table with the 'name' column:
+-----------+--------------+------+-----+---------+----------------+
| Field     | Type         | Null | Key | Default | Extra          |
+-----------+--------------+------+-----+---------+----------------+
| id        | int(11)      | NO   | PRI | NULL    | auto_increment |
| name      | varchar(100) | NO   |     | NULL    |                |
| app_label | varchar(100) | NO   | MUL | NULL    |                |
| model     | varchar(100) | NO   |     | NULL    |                |
+-----------+--------------+------+-----+---------+----------------+

So drop the table and let syncdb recreate it as required for the Django version. Take a dump if nervous about dropping it: mysqldump -u <mysqladminname> -p <databasename> django_content_type > /tmp/django_content_type.dmp


I had this same issue just now and it was related to different versions of django. I updated all of the machines working on my project to django 1.8 using pip install -U Django and everything worked fine after that.


it's not django error, it's MySQL. I just started a project, but changed django version from 1.8 to 1.7 and got this error. So, I droped all table and run migrate. But you don't need to drop all tables, just part, may be just one.

Tags:

Python

Django