1👍
✅
There’s no reason not to use the django.contrib.admin.autodiscover
, even if you subclassed AdminSite
. This is the actual instrumentation that imports the admin
module from all your Django applications registered in settings.INSTALLED_APPS
, effectively registering the models with your admin site instance.
To recap if you have a project.admin.foo_site
instance of your project.admin.FooAdminSite
subclass:
# project/urls.py
from django.conf.urls import url
from django.contrib import admin
from project.admin import foo_site
admin.autodiscover()
urlpatterns = patterns('',
url(r'^admin/', include(foo_site.urls)),
)
#project/app/admin.py
from project.admin import foo_site
from project.app.models import Bar
foo_site.register(Bar)
0👍
You need to set up an admin.py and register your models. Here’s a paraphrased version from the Django Tutorial:
To do this, create a file called admin.py in your app directory, and
edit it to look like this:
from django.contrib import admin
from app.models import Model1, Model2, Model3
admin.site.register(Model1)
admin.site.register(Model2)
admin.site.register(Model3)
- [Answer]-Show/Make a field editable or disabled in admin based on other field's value
- [Answer]-Creating a value in django template form
- [Answer]-Redirected more times than rediection_limit allows – python/Django
- [Answer]-How to filter the events based on the tags entered?
- [Answer]-Django model – queryset issue
Source:stackexchange.com