Opened 18 years ago
Closed 18 years ago
#2601 closed defect (worksforme)
Question on tutorial1
Reported by: | Owned by: | Jacob | |
---|---|---|---|
Component: | Documentation | Version: | 0.95 |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In polls/models.py, we have already two class :
from django.db import models # Create your models here. class Poll(models.Model): question = models.CharField(maxlength=200) pub_date = models.DateTimeField('date published') class Choice(models.Model): poll = models.ForeignKey(Poll) choice = models.CharField(maxlength=200) votes = models.IntegerField()
Do we have to add str() methodes after pub_date and votes line or to remove them ?
If I do :
from django.db import models import datetime # Create your models here. 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.pub_date.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
it seems it does not work... and I do not have :
# Make sure our __str__() addition worked. >>> Poll.objects.all() [<Poll: What's up?>]
Cf : http://www.djangoproject.com/documentation/tutorial1/
What do I miss ??
Note:
See TracTickets
for help on using tickets.
General support questions need to be sent to the django-users mailing list (http://groups.google.com/group/django-users), or asked in the Django IRC channel (#django on irc.freenode.net); this system is for reporting known bugs in Django.