Django Models (1054, "Unknown column in 'field list'")

Normally I get this when when I'm trying to access field which doesn't exist in Database.

Check if the field exist in the database. If you change model and perform syncdb it won't update the database, I'm not sure if that's the case.

On other note Django offers shortcut to replace try/except block in your code using get_object_or_404. (available in django.shortcuts )

try:
     user = User.objects.get(username=username)
except:
     raise Http404('Requested user not found.')

can be changed to:

user = get_object_or_404(User, username=username)

As @inception said my tables schema had changed & running syncdb did not update already created tables.

Apparently any changes to the models when updated through syncdb does not change (as in update/modify) the actual tables. So I dropped the relevant DB & ran syncdb on empty DB. Now it works fine. :)

For others, SOUTH data migration tool for Django seems to be favorite option. It seems to provide options which django models & syncdb falls short on. Must check out...

Update 29th Sept 2019: From Django 1.7 upwards, migrations are built into the core of Django. If you are running a previous lower version of Django, you can find the repository on BitBucket.


maybe your tables schema has been changed? Also, running syncdb does not update already created tables.

You might need to drop all the tables & then run syncdb again. Also remember to take backup of your data!!