Hi Jirka Thanks for your answer!
By structure I mean, I just followed the tutorial and am not sure if the position and order of these tutorial code is right in my code: class Poll(models.Model): # ... def __unicode__(self): return self.question class Choice(models.Model): # ... def __unicode__(self): return self.choice AND import datetime # ... class Poll(models.Model): # ... def was_published_today(self): return self.pub_date.date() == datetime.date.today() And I know the result is wrong because in the API it does not return what the tutorial says should be returned: TUTORIAL: >>> from mysite.polls.models import Poll, Choice # Make sure our __unicode__() addition worked. >>> Poll.objects.all() [<Poll: What's up?>] ME: >>> Poll.objects.all() [<Poll: Poll object>] Thanks for the time! Best Z. On May 11, 12:03 pm, Jirka Vejrazka <jirka.vejra...@gmail.com> wrote: > > class Choice(models.Model): > > poll = models.ForeignKey(Poll) > > choice = models.CharField(max_length=200) > > votes = models.IntegerField() > > def __unicode__(self): > > return self.question > > > I know the structure is wrong. > > Any suggestions would be greatly appreciated. > > Hi, > > I'm not sure why you'd think the structure is wrong (i.e. state > actual errors or problems rather than generic statements). > > However there is one problem with your Choice model. It does not > have any self.question, so __unicode__() can't really return it. You > probaby want to use "return self.choice" there (or compose some text > string based on existing model fields). > > HTH > > Jirka > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.