alesdotio / django-admin-shortcuts

Add simple and pretty shortcuts to the django admin homepage.
Other
205 stars 53 forks source link

optionally get the configuration from the context #3

Closed beniwohli closed 12 years ago

beniwohli commented 12 years ago

this allows (in an unfortunately quite crude way) to set per-adminsite configuration:

from django.contrib.admin import AdminSite

class SimpleAdmin(AdminSite):
    # todo: add templates here (see attrs on base class)
    ADMIN_SHORTCUTS = [{
        'shortcuts': [{
            'url': '/',
            'open_new_window': True,
        },],
    },]

    def index(self, request, extra_context=None):
        extra_context = extra_context or {}
        extra_context['ADMIN_SHORTCUTS'] = self.ADMIN_SHORTCUTS
        return super(SimpleAdmin, self).index(request, extra_context)

supplier_admin = SimpleAdmin()