Opened 13 years ago
Closed 12 years ago
#18180 closed New feature (duplicate)
add get_context_data to ModelAdmin/AdminSite
Reported by: | Stefano Apostolico | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Design decision needed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
add get_context_data to ModelAdmin/AdminSite
it's useful have a common place where configure common context variables ( as in class based view ).
Both ModelAdmin/AdminSite have no similar method, and you are forced to override all the views to put a
common object into the context (context processor is not a good solution because is involved also in non-admin's views).
The patch simply add get_context_data(**kwargs)
to ModelAdmin/AdminSite and change lines like
context = {'key':value}
to
context = self.get_context_data(**{'key':value})
if the idea is good maybe the patch can be changed to
context = self.get_context_data(key1=val1, key2=val2,)
Attachments (1)
Change History (5)
by , 13 years ago
Attachment: | admin_common_context.diff added |
---|
comment:1 by , 13 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
follow-up: 3 comment:2 by , 12 years ago
follow-up: 4 comment:3 by , 12 years ago
Type: | Bug → New feature |
---|
comment:4 by , 12 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
This seems useful, however I think this should first be considered as part of the CBV-refactoring experiment in #17208.