> I'm just going through the mysite tutorial and can't seem to get the
> __str__() method to work when adding it to the two classes, I still
> get [<Poll: Poll object>].
>
> polls/models.py:
>
> from django.db import models
> import datetime
>
> class Poll(models.Model):
>    question = models.CharField(maxlength=200)
>    pub_date = models.DateTimeField('date published')
> def __str__(self):
>               return self.question
> def was_published_today(self):
>               return self.pubdate.date() == datetime.date.today()
>
> class Choice(models.Model):
>    poll = models.ForeignKey(Poll)
>    choice = models.CharField(maxlength=200)
>    votes = models.IntegerField()
> def __str__(self):
>               return self.choice

Are you using django 0.96, or the SVN version? For the latter, you'll  
need to change __str__() to __unicode__(): 
http://www.djangoproject.com/documentation/tutorial01/ 
  and search for __str__


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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