Hi guys.
I'm just going through the official tutorial for Django: "Writing your first Django app, part 1"
At the bottom of the page it says:
# Make sure our custom method worked.
>>> p = Poll.objects.get(pk=1)
>>> p.was_published_recently()
True
So far everything went well but now cmd returns:
TypeError: unsupported operand type(s) for -: 'function' and
'datetime.timedelta'
WHAT CAN I DO TO FIX IT??
So far my cone in \polls\models.py:
from django.db import models
import datetime
from django.utils import timezone
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_recently(self):
return self.pub_date >= timezone.now - datetime.timedelta(days=1)
class Choice(models.Model):
poll= models.ForeignKey(Poll)
choice = models.CharField(max_length=200)
votes = models.IntegerField()
def __unicode__(self):
return self.choice
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4fce47e6-0b29-4bb8-9c33-fd041fa9c960%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment