p.choice_set.all() error
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 "", line 1, in 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'") -- 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 django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out. from django.db import models import datetime from django.utils import timezone # Create your models here. class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') def __unicode__(self): return self.question def was_published_recently(self): return self.pub_date >= timezone.now() - datetime.timedelta(days=1) class Choice(models.Model): poll = models.ForeignKey(Poll) choice_text = models.CharField(max_length=200) votes = models.IntegerField(default=0) def __unicode__(self): return self.choice_text
Re: p.choice_set.all() error
Thanks for the feedback. It's much appreciated. On Thursday, March 7, 2013 10:39:42 PM UTC-5, Hugo Guzman 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 "", line 1, in > 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'") > > > -- 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 django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.