On Tue, May 11, 2010 at 6:15 AM, HelloWorld <zuckerp...@gmail.com> wrote:
> 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() > > If you are saying that you repeated the "class Poll" line, first with the __unicode__ method defined and then later with the was_published_today method, you are right that that is incorrect. The "class Poll(model.Model):" line should appear only once in the file, and indented beneath it should be all of the fields and methods for the Poll model. If you repeat "class Poll...", then whatever follows that line will completely replace the previous definition for the Poll class, which is not what you want, and would lead to the result you show (no apparent definition of the __unicode__ method for Poll, since you overwrite the Poll-with-unicode version with the Poll-with-was_published_today version). Karen -- http://tracey.org/kmt/ -- 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.