On Thu, 2009-06-11 at 09:04 -0700, Sean Brant wrote:
> If I have 2 sql queries one with a limit of 5 and the other with a
> limit or 6 they return there results in diffrent orders.
> 
> Here is a example.
> 
> >>> class Book(models.Model):
> >>>    title = models.CharField(max_length=150)
> >>>    author = models.CharField(max_length=100)
> 
> >>> book_list_1 = Books.objects.order_by('author')[0:5]
> >>> book_list_2 = Books.objects.order_by('author')[0:6]
> 
> >>> print book_list_1
> <<< [<Book: Book1>, <Book: Book2>, <Book: Book3>, <Book: Book4>,
> <Book: Book6>]
> 
> >>> print book_list_2
> <<< [<Book: Book1>, <Book: Book6>, <Book: Book2>, <Book: Book3>,
> <Book: Book5>, <Book: Book4>]
> 
> Very confused.

Django just returns them in the order your database engine returns them.
If you look at django.db.connection.queries, and run them in your db
shell, they will return the items in a different order. What's causing
that is interesting though, what db engine do you use?

Might be interesting to see the queries, and also book_list_n.values().

Cheers

Tom


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to