I have a question concerning some queryset behaviour in Django 1.1.
In this example, I have an article model that can contain 1 or more
authors who are users registered through Django's auth system.
I get the following output when playing around with an article in a
shell where I have three authors:
>>> article.authors.all()
[<User: colin>, <User: blake>, <User: jeff>]
>>> article.authors.all()[0]
<User: jeff>
>>> article.authors.all()[1]
<User: blake>
>>> article.authors.all()[2]
<User: jeff>
>>> article.authors.all()[0:1]
[<User: jeff>]
>>> article.authors.all()[1:2]
[<User: blake>]
>>> article.authors.all()[2:3]
[<User: jeff>]
I'm curious why article.authors.all()[0] does not return <User: colin>
and instead returns <User: jeff>. I'm also curious as to why <User:
jeff> appears twice when slicing queries and it doesn't when
requesting all results.
Thank you in advance for your time!
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment