Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#17434 closed New feature (worksforme)

Nicer name than object_list for ListViews

Reported by: marclurr 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 4 years ago by charettes

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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

comment:2 Changed 4 years ago by mattmcc

  • Resolution set to worksforme
  • Status changed from new to closed

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

Fair enough. :-)

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