0

I am using the following to import the database entries and it works fine by listing contents from first entry to the last on the database:

users_temp = users.objects.all() --> where users is a table in my database.

How do I change the above line so that I get a list of last item on the table first and so on?

Thanks,

summerNight
  • 1,446
  • 3
  • 25
  • 52
  • i dint reallly understood what are you asking. do you want only last one? or from last to first? – sundar nataraj Jul 21 '14 at 02:35
  • It's common practice to use **upper case names** for your model classes, so you should consider using `Users` instead of `users`. – Brutus Jul 21 '14 at 09:40

1 Answers1

1

If I understood correctly you want to get the list of users in a reverse order.

reverse() was made specifically for this:

Use the reverse() method to reverse the order in which a queryset’s elements are returned.

users.objects.all().reverse()
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195