#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 , 13 years ago
comment:2 by , 13 years ago
Resolution: | → worksforme |
---|---|
Status: | new → 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.
I might be wrong but isn't exactly what `get_context_object_name` do?