Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 730
matousc Avatar asked Oct 12 '14 13:10

matousc


1 Answers

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
like image 51
kpacn Avatar answered Sep 25 '22 15:09

kpacn