Search code examples
pythondjangodjango-adminmezzaninedjango-1.7

Django - custom admin page not related to a model


I am using Django 1.7 with Mezzanine. I would like to have some page in admin, where the staff can call some actions (management commands etc.) with buttons and other control elements.

I would also like to avoid creating new model, or manually create a template and add link to it (if possible).

What is the most common/clean ways how to achieve that?


Solution

  • Actually it is simpler. Just before urlpatterns in urls.py patch admin urls like that:

    def get_admin_urls(urls):
        def get_urls():
            my_urls =  patterns('',
               url(r'^$', YourCustomView,name='home'), 
            )
            return my_urls + urls
        return get_urls
    
    admin.autodiscover()
    
    admin_urls = get_admin_urls(admin.site.get_urls())
    admin.site.get_urls = admin_urls