On Fri, Mar 8, 2013 at 3:39 AM, Hugo Guzman <[email protected]> wrote:
> Hey there. I'm working through Part I of the "Writing your first Django app"
> tutorial and everything was going smoothly until I tried executing the
> following command:
>
>>>> p.choice_set.all()
>
> When I try running it I get the proceeding errors (below). I've attached my
> models.py file for context. Any help or guidance would be much appreciated.
>
> Traceback (most recent call last):
>   File "<console>", line 1, in <module>
>   File
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/query.py",
> line 72, in __repr__
>     data = list(self[:REPR_OUTPUT_SIZE + 1])
>   File
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/query.py",
> line 87, in __len__
>     self._result_cache.extend(self._iter)
>   File
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/query.py",
> line 291, in iterator
>     for row in compiler.results_iter():
>   File
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/sql/compiler.py",
> line 763, in results_iter
>     for rows in self.execute_sql(MULTI):
>   File
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/sql/compiler.py",
> line 818, in execute_sql
>     cursor.execute(sql, params)
>   File
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/backends/util.py",
> line 40, in execute
>     return self.cursor.execute(sql, params)
>   File
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/backends/mysql/base.py",
> line 114, in execute
>     return self.cursor.execute(query, args)
>   File "/home/hugodev/dev/lib/python2.7/site-packages/MySQLdb/cursors.py",
> line 201, in execute
>     self.errorhandler(self, exc, value)
>   File
> "/home/hugodev/dev/lib/python2.7/site-packages/MySQLdb/connections.py", line
> 36, in defaulterrorhandler
>     raise errorclass, errorvalue
> DatabaseError: (1054, "Unknown column 'polls_choice.choice_text' in 'field
> list'")

This means that the database table exists, but it is missing a field
that is in your models.py.

This normally means you have changed your model after you created the table.

Django cannot automatically modify your DB tables when you change your
models.py (although there are packages like django-south that help you
manage making the changes), so you need to either manually modify the
table, or remove the table and re-run 'python manage.py syncdb', which
will re-create it (without any data).

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to