Friday, January 20, 2017

Re: "Polls" app in Django Beginners' Tutorial

Perhaps you forgot the '-' before pub_date?

On Thursday, January 19, 2017 at 8:21:32 PM UTC+1, DjangoUserDM wrote:

I have a question about the "Polls" app, as described in the Django Beginners' Tutorial, https://docs.djangoproject.com/en/1.10/intro/.  In tutorial 3, the index view contains the following code:

 

latest_question_list = Question.objects.order_by('-pub_date')[:5]

 

It is stated that this produces the latest 5 questions according to publication date.  The '-' in front of 'pub_date' is intended to return the questions in descending rather than ascending order of publication date.  Yet when I tried this out, it returns the *earliest* 5 questions in my database.  Is this an error, or (more likely), have I done something wrong?

 

Thanks for any advice!

 

David

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5aa803ed-5305-4004-a28f-5609869f8f56%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment