Ticket #8522: ticket8522-r8520.diff

File ticket8522-r8520.diff, 1.4 KB (added by jezdez, 7 years ago)

Small patch to add support for extra_context in app_index method

  • django/contrib/admin/sites.py

    diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py
    index 9c5a5f1..edbc876 100644
    a b class AdminSite(object): 
    366366            context_instance=template.RequestContext(request)
    367367        )
    368368       
    369     def app_index(self, request, app_label):
     369    def app_index(self, request, app_label, extra_context=None):
    370370        user = request.user
    371371        has_module_perms = user.has_module_perms(app_label)
    372372        app_dict = {}
    class AdminSite(object): 
    399399                        raise http.Http404('The requested admin page does not exist.')
    400400        # Sort the models alphabetically within each app.
    401401        app_dict['models'].sort(lambda x, y: cmp(x['name'], y['name']))
    402         return render_to_response(self.app_index_template or 'admin/app_index.html', {
     402        context = {
    403403            'title': _('%s administration' % capfirst(app_label)),
    404404            'app_list': [app_dict]
    405         }, context_instance=template.RequestContext(request))
     405        }
     406        context.update(extra_context or {})
     407        return render_to_response(self.app_index_template or 'admin/app_index.html', context,
     408            context_instance=template.RequestContext(request)
     409        )
    406410
    407411# This global object represents the default admin site, for the common case.
    408412# You can instantiate AdminSite in your own code to create a custom admin site.
Back to Top