Sites and Auth apps not visible on using custom AdminSite

250 views
Skip to first unread message

raj

unread,
Dec 29, 2008, 5:41:31 AM12/29/08
to Django users
In the usual admin index at http://host:port/admin/ page, there are
the auth and sites app visible on top of our custom app list. I'd to
customize the admin index page and the AdminSite. After that those
apps are not visible. The only change I made in the custom AdminSite
is to add two key-value pairs into the context dictionary defined at
the end of index() method as follows:

context = {
#other key-value pairs are there..
#####################
'report_form':ReportForm(),
'url_base':url_base,
#####################
}
context.update(extra_context or {})
return render_to_response(self.index_template or 'admin/
index.html',context,context_instance=template.RequestContext(request))

What is wrong with the code?

Alex Koshelev

unread,
Dec 29, 2008, 8:35:54 AM12/29/08
to django...@googlegroups.com
How have you created custom AdminSite? Have you registered auth and site models to it?
Message has been deleted

raj

unread,
Dec 29, 2008, 12:33:17 PM12/29/08
to Django users

On Dec 29, 6:35 pm, "Alex Koshelev" <daeva...@gmail.com> wrote:
> How have you created custom AdminSite? Have you registered auth and site
> models to it?

I haven't done that. Thought that being built-in apps they would
already be hooked to the parent class AdminSite. I'll try what you
suggested. But where shall the original code be found from, I mean,
those lines hooking up the auth and sites apps?

raj

unread,
Dec 29, 2008, 12:50:55 PM12/29/08
to Django users
Yes, I've found the way out. Adding these lines to the admin module
will help:

from django.contrib.sites.models import Site
from django.contrib.sites.admin import SiteAdmin
from django.contrib.auth.models import User, Group
from django.contrib.auth.admin import UserAdmin, GroupAdmin

## admin_site is an instance of my custom AdminSite class.
admin_site.register(Site, SiteAdmin)
admin_site.register(Group, GroupAdmin)
admin_site.register(User, UserAdmin)

We need to do that manually because the bulit-in 'hook-up wires' are
connected with an instance of AdminSite class called site, not to the
class. So inheritance doesn't help you there. I think this must have
been declared in the documentation.

Thanks Alex.

Alex Koshelev

unread,
Dec 29, 2008, 3:13:31 PM12/29/08
to django...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages