Django Error: OperationalError: no such table: polls_poll


Solution 1

I meet the same problem today and fix it I think you miss some command in tutorial 1 just do follow: ./python makemigrations polls
python sql polls ./python syncdb

then fix it and gain the table polls and you can see the table created you should read the " makemigrations" command

Solution 2

i figured out the mistake you did, after making changes to your you should run migrate ..i.e

    python migrate

then only your changes(polls_question) will be visible

Solution 3

For those encountering this error in the current django 3.0 release (, you can rectify it by making sure you've run the following commands in order.

python makemigrations polls

python sqlmigrate polls 0001

python migrate

Solution 4

I've just solved this problem in a very easy and effective way.

This error is coming because of wrong pycache and db.sqlite3 in django To solve this error we can delete those files and re-make it.

Delete pycache and db.sqlite3 manually.

then run this in terminal:

 python makemigrations polls    

After this your database and __pycache will be created again. And just make migrations, it will work fine.

Of course you might want to store your data before deleting database.

Author by


Time Traveller. I wrote and created Fire - Cryptocurrency Portfolio using Nativescript.

Updated on July 01, 2022


  • razorsyntax
    razorsyntax 6 months

    Going through Django tutorial 1 using Python 2.7 and can't seem to resolve this error: OperationalError: no such table: polls_poll

    This happens the moment I enter Poll.objects.all() into the shell.

    Things I've already tried based on research through the net:

    1) Ensured that 'polls' is listed under INSTALLED_APPS in

    Note: I've seen lots of suggestions inserting 'mysite.polls' instead of 'polls' into INSTALLED_APPS but this gives the following error: ImportError: cannot import name 'polls' from 'mysite'

    2) Run python syncdb . This creates my db.sqlite3 file successfully and seemingly without issue in my mysite folder.

    3) Finally, when I run python shell, the shell runs smoothly, however I do get some weird Runtime Warning when it starts and wonder if the polls_poll error is connected: \django\db\backends\sqlite3\ RuntimeWarning: SQLite received a naive datetime (2014-02-03 17:32:24.392000) while time zone support is active.

    Any help would be appreciated.

  • Patrick
    Patrick almost 8 years
    polls is actually the name of the app listed under INSTALLED_APPS
  • Homunculus Reticulli
    Homunculus Reticulli over 5 years
    It is important to point out that it is almost always better to type python makemigrations <appname> as opposed to python makemigrations since sometimes, not all applications are picked up - this happened to be the case for me, because I had made a lot of manual modifications to the underlying code, app directory names etc. Sometimes, django can get "out of sync" - and so its always best to explicitly state the application whose model is to be migrated.