Opened 17 years ago

Closed 16 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)

patch.diff (3.4 KB ) - added by Grimboy 17 years ago.
object_list_accept_list.diff (2.7 KB ) - added by Grimboy 17 years ago.
Using documentation conventions.
object_list_accept_list_v2.diff (4.0 KB ) - added by frankie@… 17 years ago.
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.
object_list_accept_list_v3.diff (4.1 KB ) - added by frankie@… 17 years ago.
Fixed silly bug from using if foo rather than if foo is not None. Against [4750].

Download all attachments as: .zip

Change History (11)

by Grimboy, 17 years ago

Attachment: patch.diff added

by Grimboy, 17 years ago

Using documentation conventions.

by frankie@…, 17 years ago

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 anonymous, 17 years ago

Cc: frankie@… added

comment:2 by Simon G. <dev@…>, 17 years ago

Triage Stage: UnreviewedDesign decision needed

comment:3 by Gary Wilson <gary.wilson@…>, 17 years ago

Please note that #3181 was marked a duplicate of this and had an alternative patch.

comment:4 by James Bennett, 17 years ago

I'd be +1 on this since it would mean generic views could work with other ORMs.

comment:5 by frankie@…, 17 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 frankie@…, 17 years ago

Fixed silly bug from using if foo rather than if foo is not None. Against [4750].

comment:6 by Chris Beaven, 17 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 Jacob, 16 years ago

Resolution: wontfix
Status: newclosed

No, this is by design: generic views operate on querysets. If you need different behavior, you'll need to write your own views.

Note: See TracTickets for help on using tickets.
Back to Top