#4905: __unicode__
-----------------------------------------+----------------------------------
Reporter: [EMAIL PROTECTED] | Owner: jacob
Status: new | Component: Documentation
Version: SVN | Keywords:
Stage: Unreviewed | Has_patch: 0
-----------------------------------------+----------------------------------
Hi
Beginner question. Is there any reason why def __unicode__(self): do not
work ?
>>> n= Poll(question="What's up dude ?", pub_date=datetime.now())
>>> n.save()
>>>Poll.objects.get(pk=1)
<Poll: Poll object>
from django.db import models
import datetime
class Poll(models.Model):
question = models.CharField(maxlength=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(maxlength=200)
votes = models.IntegerField()
def __unicode__(self):
return self.choice
Thanks in advance
Alex
--
Ticket URL: <http://code.djangoproject.com/ticket/4905>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" 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-updates?hl=en
-~----------~----~----~----~------~----~------~--~---