Skip to content Skip to sidebar Skip to footer

Django Operationalerror: No Such Column: On Pythonanywhere

First, I was able to fix the ImportError. I figured out that it was because the Django version of pythonanywhere is not updated, So I upgraded Django on pythonanywhere from 1.x.x t

Solution 1:

The problem as I see has to be with the database and django migrations.

The Post object inside the blog has the attribute that django's trying to find. The migrations haven't been correctly applied to the database.

Now considering the history of migrations, I do not know what's going wrong unless I can look around your database which I'm assuming is an sqlite.

One way to resolve this if you're having a newly constructed database is to get rid of the database and do the following:

  • Delete all the migrations from app/migrations directory
  • python manage.py makemigrations
  • python manage.py migrate

Also, try to avoid sqlite as much as possible. The same migrations that ran on an sqlite db might be erroneous on Postgres or MySQL database which are more production grade databases.

NOTE: Please understand that this would lead to a complete data loss. Hence, try this only if you can afford to compromise on the existing/test data.

Solution 2:

Don't forget to refresh your production server after every migration if you want the changes to take effect

Post a Comment for "Django Operationalerror: No Such Column: On Pythonanywhere"