Opened 7 years ago

Closed 7 years ago

Last modified 7 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


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 Changed 7 years ago by Simon Charette

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

comment:2 Changed 7 years ago by Matt McClanahan

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 Changed 7 years ago by anonymous

Fair enough. :-)

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