Opened 3 years ago

Closed 3 years ago

#18180 closed New feature (duplicate)

add get_context_data to ModelAdmin/AdminSite

Reported by: saxix Owned by: nobody
Component: contrib.admin Version: master
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 saxix 3 years ago.

Download all attachments as: .zip

Change History (5)

Changed 3 years ago by saxix

comment:1 Changed 3 years ago by jezdez

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

comment:2 follow-up: Changed 3 years ago by julien

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

comment:3 in reply to: ↑ 2 ; follow-up: Changed 3 years ago by saxix

  • Type changed from Bug to New 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)

comment:4 in reply to: ↑ 3 Changed 3 years ago by kmtracey

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

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