Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSahar Nasiri
7,454 PointsI have a weird error
Here is my code: https://w.trhou.se/0a3s6wn62p
When I type Course.objects.all() I get an Import error while I have imported Course class. What does this error mean? And how can I fix it?
Sahar Nasiri
7,454 Points>>> Course.objects.all()
Traceback (most recent call last):
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/django/core/management/commands/shell.py", l
ine 69, in handle
self.run_shell(shell=options['interface'])
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/django/core/management/commands/shell.py", l
ine 61, in run_shell
raise ImportError
ImportError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in ex
ecute
return self.cursor.execute(sql, params)
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py", line 32
3, in execute
return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: no such table: courses_course
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/django/db/models/query.py", line 234, in __r
epr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/django/db/models/query.py", line 258, in __i
ter__
self._fetch_all()
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/django/db/models/query.py", line 1074, in _f
etch_all
self._result_cache = list(self.iterator())
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/django/db/models/query.py", line 52, in __it
er__
results = compiler.execute_sql()
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 848,
in execute_sql
cursor.execute(sql, params)
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/django/db/backends/utils.py", line 79, in ex
ecute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in ex
ecute
return self.cursor.execute(sql, params)
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/django/db/utils.py", line 95, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in ex
ecute
return self.cursor.execute(sql, params)
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py", line 32
3, in execute
1 Answer
Chris Freeman
Treehouse Moderator 68,454 PointsThe line "sqlite3.OperationalError: no such table: courses_course
" implies that while the models.py
has been updated to include the Course
class, the database file either hasn't been initialized with a manage.py syncdb
or hasn't been updated with a migration.
Chris Freeman
Treehouse Moderator 68,454 PointsChris Freeman
Treehouse Moderator 68,454 PointsCan you please post the input used and error stacktrace you see?