Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Error: OperationalError: no such table: polls_poll

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 settings.py

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 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.

like image 898
razorsyntax Avatar asked Nov 30 '22 00:11

razorsyntax


1 Answers

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

like image 92
Michael Avatar answered Dec 07 '22 23:12

Michael