Tuesday, January 25, 2011

Multiple Admins, improper object linking

Hi,

I have a lot of admin customization. Queryset overriding, custom urls per object, per admin site, save methods overriding and calling some external services, template changes, you name it.

So, In my application, I like to have another instance of admin I call "bare-tables" in which I auto register all existing models in a project level admin.py using the following:

from django.db.models import get_models
from django.contrib.admin import AdminSite
from reversion.admin import VersionAdmin

class BareTables(AdminSite):
    pass

new_admin = BareTables(name='bare_tables')

for el in get_models():
    new_admin.register(el,VersionAdmin)


And I link up both the admins in the URL using the following:

urlpatterns = patterns('',
    url(r'^admin_tools/', include('admin_tools.urls')),
    (r'^admin/doc/', include('django.contrib.admindocs.urls')),
    (r'^admin/', include(admin.site.urls)),
    (r'^bare-tables/', include(new_admin.urls)),
    
I was all good and happy. Except, I included the admin tools, to customize only the first admin with all the Jazz, dashboard and menus, the way I like it. Now, when I go to the admin, or to the plain admin that I called "bare-tables", the objects are linked to the main admin. :( If I manually change the "admin" in the url above to "bare-tables", it works.

I think the problem is that admin_tools templates don't use the prefix to reverse the urls, or that I need to pass it the prefix somehow and I am not. What simple change that I can make to make it work properly. I am ok, even if the plain admin retains the old skin, Is there a way I can tell admin-tools, not to get involved if the base url is something.

-Regards,
Lakshman


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

No comments:

Post a Comment