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'")


-- 
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.


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






Reply via email to