On Sep 1, 7:28 pm, Erskine <[email protected]> wrote: > Hi, > > I've just started using Django and have been following the 'Writing > your first Django App' tutorial. So far so good, but I've run into a > little irritation - the use of the _unicode_ method doesn't work for > me. I'm using Django 1.2.1. I'm pretty sure I've got the indenting > right, but when I run the Python shell the only response I get for > Poll.objects.all() is Polls: poll objects and not the objects > themselves. This is my code as I've been following along on Page 1 of > the tutorial. > > Thanks > > from django.db import models > import datetime > > 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_today(self): > return self.pub_date.date() == datetime.date.today() > > class Choice(models.Model): > poll = models.ForeignKey(Poll) > choice = models.CharField(max_length=200) > votes = models.IntegerField() > def _unicode_(self): > return self.choice
It's two underscores each side, not one - __unicode__, not _unicode_. -- DR. -- 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.

