Django

Code

Ticket #3168 (closed: wontfix)

Opened 2 years ago

Last modified 1 year ago

[patch] object_list should accept lists as well as QuerySets

Reported by: Grimboy Assigned to: nobody
Milestone: Component: Generic views
Version: Keywords:
Cc: frankie@grimboy.co.uk Triage Stage: Design decision needed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 1

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

patch.diff (3.4 kB) - added by Grimboy on 12/19/06 19:43:56.
object_list_accept_list.diff (2.7 kB) - added by Grimboy on 12/19/06 21:56:13.
Using documentation conventions.
object_list_accept_list_v2.diff (4.0 kB) - added by frankie@grimboy.co.uk on 12/21/06 12:58:11.
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@grimboy.co.uk on 03/17/07 11:33:43.
Fixed silly bug from using if foo rather than if foo is not None. Against [4750].

Change History

12/19/06 19:43:56 changed by Grimboy

  • attachment patch.diff added.

12/19/06 21:56:13 changed by Grimboy

  • attachment object_list_accept_list.diff added.

Using documentation conventions.

12/21/06 12:58:11 changed by frankie@grimboy.co.uk

  • 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.

12/21/06 13:00:23 changed by anonymous

  • cc set to frankie@grimboy.co.uk.

02/10/07 04:53:08 changed by Simon G. <dev@simon.net.nz>

  • stage changed from Unreviewed to Design decision needed.

02/27/07 13:34:19 changed by Gary Wilson <gary.wilson@gmail.com>

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

02/27/07 14:08:04 changed by ubernostrum

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

03/16/07 19:49:12 changed by frankie@grimboy.co.uk

So we are currently +3 (me, arockstar@gmail.com of the other patch and ubernostrum) and -0. Anyone going to object or should this be moved onto ready for checkin?

03/17/07 11:33:43 changed by frankie@grimboy.co.uk

  • attachment object_list_accept_list_v3.diff added.

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

08/07/07 06:34:40 changed by SmileyChris

  • needs_better_patch set to 1.

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.

12/02/07 13:55:04 changed by jacob

  • status changed from new to closed.
  • resolution set to wontfix.

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


Add/Change #3168 ([patch] object_list should accept lists as well as QuerySets)




Change Properties
Action