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 trial

Python Django Basics Model Administration Adding Instances

weird error

I get a lot of lines in an err every time I type anything in the shell, especially adding a new description or typing 'ObjectName.objects.all().

These two seem the most important:

This is in the middle of the error: sqlite3.OperationalError: no such column: practice_example.description

On the last line of the err message is this: django.db.utils.OperationalError: no such column: practice_example.description

I read someone else's question similar to this and the response was that she must have forgotten to do makemigration and migrate. I did so.

This is a good question and out of my expertise. Kenneth Love do you have any ideas?

1 Answer

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

That message reads exactly like you missed the migrations. Double check the migrations folder in that app and make sure there are some that reference your model?

That did work. Thank you. Now the str function won't run. I just typed: def str(self): return self.title within the scope of the class we built. I looked online and the only person I found with the same problem used 'unicode' to fix the issue. That is for python 2 though.

This is the error I got back.

Traceback (most recent call last): File "C:\Users\ekwoo\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\backends\utils.py", line 64, in execute return self.cursor.execute(sql, params) File "C:\Users\ekwoo\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\backends\sqlite3\base.py", line 337, in execute return Database.Cursor.execute(self, query, params) sqlite3.OperationalError: no such column: practice_example.title The above exception was the direct cause of the following exception: Traceback (most recent call last): File "<input>", line 1, in <module> File "C:\Users\ekwoo\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\models\query.py", line 232, in repr data = list(self[:REPR_OUTPUT_SIZE + 1]) File "C:\Users\ekwoo\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\models\query.py", line 256, in iter self.fetch_all() File "C:\Users\ekwoo\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\models\query.py", line 1087, in _fetch_all self._result_cache = list(self.iterator()) File "C:\Users\ekwoo\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\models\query.py", line 54, in __iter_ results = compiler.execute_sql() File "C:\Users\ekwoo\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\models\sql\compiler.py", line 835, in execute_sql cursor.execute(sql, params) File "C:\Users\ekwoo\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\backends\utils.py", line 79, in execute return super(CursorDebugWrapper, self).execute(sql, params) File "C:\Users\ekwoo\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\backends\utils.py", line 64, in execute return self.cursor.execute(sql, params) File "C:\Users\ekwoo\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\utils.py", line 94, in exit six.reraise(dj_exc_type, dj_exc_value, traceback) File "C:\Users\ekwoo\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\utils\six.py", line 685, in reraise raise value.with_traceback(tb) File "C:\Users\ekwoo\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\backends\utils.py", line 64, in execute return self.cursor.execute(sql, params) File "C:\Users\ekwoo\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\backends\sqlite3\base.py", line 337, in execute return Database.Cursor.execute(self, query, params) django.db.utils.OperationalError: no such column: practice_example.title