Opened 19 years ago
Closed 18 years ago
#3168 closed enhancement (wontfix)
[patch] object_list should accept lists as well as QuerySets
| Reported by: | Grimboy | Owned by: | nobody |
|---|---|---|---|
| Component: | Generic views | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | frankie@… | Triage Stage: | Design decision needed |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | yes |
| Easy pickings: | no | UI/UX: | no |
Description
object_list should accept lists as well as QuerySets. This is perhaps a matter of opinion. Obviously getting access to a list in urls.py isn't practical. However, lots of people use generic views as a way to "finish off" real views. It therefore seems a bit limiting to only accept QuerySets. A view may parse some items in an xml file and return them as a list or may do a raw SQL query rather than using Django's ORM. So this is not an impractical addition.
I haven't renamed the queryset argument since it is often specified by keyword. Another, perhaps cleaner solution would be to rename queryset to sequence and accept queryset as a deprecated (or not) argument.
Attachments (4)
Change History (11)
by , 19 years ago
| Attachment: | patch.diff added |
|---|
by , 19 years ago
| Attachment: | object_list_accept_list.diff added |
|---|
by , 19 years ago
| Attachment: | object_list_accept_list_v2.diff added |
|---|
This version doesn't force what obviously aren't QuerySets to be passed in by queryset=* while keeping compatibility. Not sure if this is more or less confusing than the previous one.
comment:1 by , 19 years ago
| Cc: | added |
|---|
comment:2 by , 19 years ago
| Triage Stage: | Unreviewed → Design decision needed |
|---|
comment:3 by , 19 years ago
Please note that #3181 was marked a duplicate of this and had an alternative patch.
comment:4 by , 19 years ago
I'd be +1 on this since it would mean generic views could work with other ORMs.
comment:5 by , 19 years ago
So we are currently +3 (me, arockstar@… of the other patch and ubernostrum) and -0. Anyone going to object or should this be moved onto ready for checkin?
by , 19 years ago
| Attachment: | object_list_accept_list_v3.diff added |
|---|
Fixed silly bug from using if foo rather than if foo is not None. Against [4750].
comment:6 by , 18 years ago
| Patch needs improvement: | set |
|---|
I much prefer the version before another keyword was introduced.
Needs improvement because it should be using isinstance(queryset, QuerySet) in case it's a subclass.
comment:7 by , 18 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
No, this is by design: generic views operate on querysets. If you need different behavior, you'll need to write your own views.
Using documentation conventions.