On other day, i struggle with django. WOW. I need a quick dashboard not all that apps lists. I usually use django-suit for my projects and that's really awesome. So make a new administration, no. The main admin do at i need but i want only a custom dashboard. Apply some freak apps to modify my main dashboard, nope i want total control to insert i want. So after many patch, try, error, do it something to it. What i'be done was simple subclass AdminSite an override the get_urls and put my custom index view on it.
So created a app called plus. In there a inserted two files, sites.py and views.py. On sites did this:
from django.contrib.admin.sites import AdminSite
"""Mixin for AdminSite to allow custom dashboard views."""
def __init__(self, *args, **kwargs):
return super(AdminMixin, self).__init__(*args, **kwargs)
"""Add our dashboard view to the admin urlconf. Deleted the default index."""
from django.conf.urls import patterns, url
from views import DashboardWelcomeView
urls = super(AdminMixin, self).get_urls()
custom_url = patterns('',
return custom_url + urls
class SitePlus(AdminMixin, AdminSite):
A Django AdminSite with the AdminMixin to allow registering custom
from django.views.generic import TemplateView
template_name = 'admin/dashboard/welcome.html'
def get(self, request, *args, **kwargs):
context = self.get_context_data(**kwargs)
Now our class for override on urls are ready. Let's make it happen.
from django.contrib import admin
from websublime.contrib.manager.plus.sites import SitePlus
admin.site = SitePlus()
urlpatterns = patterns('',
Admin site takes our new class to resolve our custom view. I made a TemplateView but it's up to you if you want on self index() or a custom view.
So, where it is my new dashboard view. As i said, if you use django-suit for template you will have a menu on left for your application and now a custom space for you dashboard. And that's it.