Hi,

I wanted to expand the Poll example in the first tutorial by
organizing polls in groups. I thought this could be done by simply
adding a Foreign key to the Poll class.

from django.db import models

class Pollgroup(models.Model):
    name = models.CharField(maxlength=200)

class Poll(models.Model):
    pollgroup = models.ForeignKey(Pollgroup)
    question = models.CharField(maxlength=200)
    pub_date = models.DateTimeField('date published')

class Choice(models.Model):
    poll = models.ForeignKey(Poll)
    choice = models.CharField(maxlength=200)
    votes = models.IntegerField()

However, when I now try to create a new object in the Choice class and
add it to an object in the Poll class, it says that the question
object has no choice attribute. I use a Python shell and follow the
same procedure as in the tutorial.

>>> p = Poll.objects.get(pk=1)
>>> p.choice_set.create(choice='Not much', votes=0)
<Choice: Not much>

Why do I get this error message?

I have django 0.96 installed.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to