Opened 12 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)

admin_common_context.diff (6.8 KB ) - added by Stefano Apostolico 12 years ago.

Download all attachments as: .zip

Change History (5)

by Stefano Apostolico, 12 years ago

Attachment: admin_common_context.diff added

comment:1 by Jannis Leidel, 12 years ago

Triage Stage: UnreviewedDesign decision needed

comment:2 by Julien Phalip, 12 years ago

This seems useful, however I think this should first be considered as part of the CBV-refactoring experiment in #17208.

in reply to:  2 ; comment:3 by Stefano Apostolico, 12 years ago

Type: BugNew feature

Replying to julien:

This seems useful, however I think this should first be considered as part of the CBV-refactoring experiment in #17208.

yep, I did not known about #17208, I agree on that and propose to close the ticket ( opened as bug by mistake, I'm sorry)

in reply to:  3 comment:4 by Karen Tracey, 12 years ago

Resolution: duplicate
Status: newclosed

Replying to saxix:

yep, I did not known about #17208, I agree on that and propose to close the ticket ( opened as bug by mistake, I'm sorry)

FYI there's no need to propose to close it, you could close it yourself. If you have not already commented on #17208 regarding this please do so.

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