#8154 closed (fixed)
QuerySet.reverse() not working as documented
Reported by: | casseen | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Keywords: | queryset reverse ordering | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The Documentation suggests that you can call the reverse() function on any queryset.
QuerySet.reverse() is only working if there is specified a default ordering in the model's meta options or the queryset has been ordered with QuerySet.order_by() previously
Change History (5)
comment:1 by , 16 years ago
milestone: | → 1.0 |
---|---|
Triage Stage: | Unreviewed → Design decision needed |
comment:2 by , 16 years ago
Yes, reverse() should not work on unordered querylist objects. I think it just has to be documented correctly. And it may throw an exception or warning when using on unordered objects.
comment:3 by , 16 years ago
Triage Stage: | Design decision needed → Accepted |
---|
The eventual patch here should just say that the results are undetermined if you use it on an unordered queryset. It shouldn't raise an error or a warning so that you can safely call reverse()
on something without worrying about whether it's ordered or not. It's harmless to do so, just not particularly useful. So this is a documentation-only issue.
comment:4 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I believe that this is likely a documentation issue. If I recall correctly, without an order_by statement in the actual SQL statement, the database itself isn't necessarily bound to returning anything in any particular order. Reversing something without an order doesn't make sense. Perhaps I'm wrong. Marking DDN.