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 trialOisin Kilkenny
14,213 PointsTable post has no column named content
After I post something I get an OperationalError saying "Table post has no column named content". I have no idea why it's saying this. I have the exact same code from the videos, I even tried it with the downloaded project files and I get the same error.
I don't know if this is of use, but I'll dump it here in case.
File "C:\Python27\lib\site-packages\flask\app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Python27\lib\site-packages\flask\app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "C:\Python27\lib\site-packages\flask\app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Python27\lib\site-packages\flask\app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "C:\Python27\lib\site-packages\flask\app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Python27\lib\site-packages\flask\app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Python27\lib\site-packages\flask\app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Python27\lib\site-packages\flask\app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Python27\lib\site-packages\flask_login.py", line 758, in decorated_view
return func(*args, **kwargs)
File "U:\python\SocialNetwork\app.py", line 89, in post
content=form.content.data.strip())
File "C:\Python27\lib\site-packages\peewee.py", line 4001, in create
inst.save(force_insert=True)
File "C:\Python27\lib\site-packages\peewee.py", line 4148, in save
pk_from_cursor = self.insert(**field_dict).execute()
File "C:\Python27\lib\site-packages\peewee.py", line 2858, in execute
cursor = self._execute()
File "C:\Python27\lib\site-packages\peewee.py", line 2371, in _execute
return self.database.execute_sql(sql, params, self.require_commit)
File "C:\Python27\lib\site-packages\peewee.py", line 3073, in execute_sql
self.commit()
File "C:\Python27\lib\site-packages\peewee.py", line 2922, in __exit__
Display the sourcecode for this frameOpen an interactive python shell in this framereraise(new_type, new_type(*exc_value.args), traceback)
File "C:\Python27\lib\site-packages\peewee.py", line 3065, in execute_sql
cursor.execute(sql, params or ())
2 Answers
Ken Alger
Treehouse TeacherOisin;
The error you are getting indicates that there is an issue with the formation of your database table. If you could post your project files (app.py
, models.py
, and forms.py
) let's see if we can get this sorted out. If you want to get a head start on the rest of us in the forum, take a look at where content
is defined and used.
Ken
Kenneth Love
Treehouse Guest TeacherDid you create and run the migrations?
Oisin Kilkenny
14,213 PointsSorry, what does that mean?
Kenneth Love
Treehouse Guest TeacherOh, sorry, wrong course.
Sounds like maybe the initialize()
didn't run. Can you run it directly? Pop into a Python shell, import the function, and run it. You might want to delete the SQLite database first, even.
Oisin Kilkenny
14,213 PointsWhere should the database be stored in order to delete it?
Kenneth Love
Treehouse Guest TeacherIt should be in the same directory as your Flask app. Should be named social.db
.
Oisin Kilkenny
14,213 PointsOkay, well I don't have that. I have: app.py, forms.py, forms.pyc, models.py, models.pyc
Kenneth Love
Treehouse Guest TeacherOK, so that's the first problem :) You don't have a database. What happens when you run app.py
?
Oisin Kilkenny
14,213 PointsI get this error: OperationalError: no such column: t1.content
Kenneth Love
Treehouse Guest TeacherYou get an operational error when you do python app.py
on your command line?
Oisin Kilkenny
14,213 PointsYes, but I get the message in the browser
Oisin Kilkenny
14,213 PointsOisin Kilkenny
14,213 Pointsapp.py
models.py
forms.py
I've looked at where content is defined, but can't seem to find my error. :(
Ken Alger
Treehouse TeacherKen Alger
Treehouse TeacherAnother quick question. Are you doing this on your local machine or in Workspaces?
Oisin Kilkenny
14,213 PointsOisin Kilkenny
14,213 PointsLocal machine, running Python 2.7.10