On my site, users submit content that needs to be approved before
getting published. Thus I wanted a simple "dashboard" on the admin
page to show me how many pending items from each model are waiting for
approval. I created a template tag for the dashboard. I then mulled my
options for getting this template tag on the admin index page. Here is
what I came up with and I'd like some feedback.

Reading the Django docs, it says that if you want to change the index
page, "you are better off creating your own AdminSite instance [...],
and changing the AdminSite.index_template". [1]

I started research that option, but I didn't need any custom behavior
from my admin site, and I already have about a dozen applications that
have admin.py files and are they are registering with the default
admin site.

So in my main urls.py file, right before the admin.autodiscover()
call, I just did this:

admin.site.index_template = 'admin/custom_index.html'
admin.autodiscover()

I then created my own template file in one of my TEMPLATE_DIRS called
'admin/custom_index.html" that extends 'admin/index.html'. I ended up
copying the {% block content %} from the admin/index.html and
inserting my template tag into it.

It works great but I can't help but be haunted by that "you are better
off creating your own AdminSite instance" bit. Am I missing something
by not doing that?

Thanks!

[1] 
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#root-and-login-templates

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to