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 manage.py makemigrations polls
python manage.py sql polls
./python manage.py syncdb
then fix it and gain the table polls and you can see the table created you should read the "manage.py makemigrations" command
Solution 2
i figured out the mistake you did, after making changes to your models.py you should run migrate ..i.e
python manage.py migrate
then only your changes(polls_question) will be visible
Solution 3
For those encountering this error in the current django 3.0 release (https://docs.djangoproject.com/en/3.0/intro/tutorial02/), you can rectify it by making sure you've run the following commands in order.
python manage.py makemigrations polls
python manage.py sqlmigrate polls 0001
python manage.py 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 manage.py 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.

razorsyntax
Time Traveller. I wrote and created Fire - Cryptocurrency Portfolio using Nativescript. https://www.biomance.com/
Updated on July 01, 2022Comments
-
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 underINSTALLED_APPS
in settings.pyNote: I've seen lots of suggestions inserting
'mysite.polls'
instead of'polls'
intoINSTALLED_APPS
but this gives the following error: ImportError: cannot import name 'polls' from 'mysite'2) Run
python manage.py syncdb
. This creates my db.sqlite3 file successfully and seemingly without issue in my mysite folder.3) Finally, when I run
python manage.py 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\base.py:63: 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 almost 8 yearspolls is actually the name of the app listed under INSTALLED_APPS
-
Homunculus Reticulli over 5 yearsIt is important to point out that it is almost always better to type
python manage.py makemigrations <appname>
as opposed topython manage.py 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.