Did you set a pub_date on the questions you created? Since the field doesn't have a default value it will remain empty and have no effect on ordering unless you explicitly set pub_date=timezone,now() every time you create a question.
On Friday, January 20, 2017 at 2:30:37 PM UTC+1, DjangoUserDM wrote: > > Here it is: > > class Question(models.Model): > question_text = models.CharField(max_length=200) > pub_date = models.DateTimeField('date published') > > def was_published_recently(self): > now = timezone.now() > return now - datetime.timedelta(days=1) <= self.pub_date <= now > > def __str__(self): > return self.question_text > -- 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+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/16750999-ac65-48b0-87c4-2fe6ce11a739%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.