Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#17434 closed New feature (worksforme)

Nicer name than object_list for ListViews

Reported by: Mark Barrett Owned by: nobody
Component: Generic views Version:
Severity: Normal Keywords: listview generic view
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I ListViews, I think it would be nice if instead of creating a context variable called object_list, it was named based on the model.

For example for the following urlconfig

Code highlighting:

(r'^publishers/$', ListView.as_view(model=User))

A variable called 'users' or 'user_list' would be added to the context.

I understand that this would break backwards compatibility, so I propose creating a new Generic View to facilitate this (for example ModelListView).

Change History (3)

comment:1 by Simon Charette, 13 years ago

I might be wrong but isn't exactly what `get_context_object_name` do?

comment:2 by Matt McClanahan, 13 years ago

Resolution: worksforme
Status: newclosed

Yep, it's already there. If you don't specify context_object_name it'll default to <model>_list. The list is also added as object_list for backwards compatibility.

comment:3 by anonymous, 13 years ago

Fair enough. :-)

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