Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My apps not visible when using custom AdminSite

I'd have a problem with custom AdminSite - my apps are not visible at the admin index and not accessible if i type appropriate URL to view their models. My problem is very similar to this: http://groups.google.com/group/django-users/browse_thread/thread/881feb7eef80853a but it's kind of reverse problem - the bundled models are visible, but my custom are not.

My project named magic and it have app. named nullt

magic/admin.py:

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

class MagicAdmin(AdminSite):
    pass

admin_site = MagicAdmin()

admin_site.register(Group, GroupAdmin)
admin_site.register(User, UserAdmin)

magic/nullt/admin.py

from magic.admin import admin_site
...
admin_site.register(Host, HostAdmin)
admin_site.register(Client, ClientAdmin)
...

magic/urls.py

from django.conf.urls.defaults import * #@UnusedWildImport
from magic.admin import admin_site

urlpatterns = patterns('',
    (r'^admin/', include(admin_site.urls)),
)

P.S. I'm using Django 1.2.2 installed with easy_install and Python 2.6.5 from Ubuntu 10.04 x86_64

like image 583
Dmitry Musatov Avatar asked Nov 06 '22 09:11

Dmitry Musatov


1 Answers

By default, the following two lines are commented in a new project's urls.py:

from django.contrib import admin
admin.autodiscover()

From django/contrib/admin/__init__.py:

def autodiscover():
    """
    Auto-discover INSTALLED_APPS admin.py modules and fail silently when
    not present. This forces an import on them to register any admin bits they
    may want.
    """

This call may be necessary, even if you have a custom admin.

like image 175
eternicode Avatar answered Nov 09 '22 12:11

eternicode