Reputation: 549
I want to have 2 separate admin sites inside a Django project.
First is default admin And Second is "coursemanager" Following code i have added with the help of AdminSite
File Path "cms/courses/admin.py"
from courses.models import *
from django.contrib import admin
from django.contrib.admin.sites import AdminSite
from django.contrib.auth.models import User, Group
from django.contrib.auth.admin import UserAdmin, GroupAdmin
class CourseManager(AdminSite):
name = 'CourseManager'
course_manager = CourseManager()
class CityAdmin(admin.ModelAdmin):
list_display = ['__unicode__', 'status',]
list_filter = ['status',]
search_fields = ['title',]
course_manager.register(City, CityAdmin)
"cms/cms/urls.py"
from courses.admin import course_manager
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'coursemanager/', include(course_manager.urls)),
)
But when i add this http://domain.local/coursemanager/ & http://domain.local/admin/ both panel is working but in http://domain.local/coursemanger/ list register city module but not showing the add or changes links. Event i tried to access links from url but not working. I am checking this as superuser and i have all modules access. But when i change code like bellow
"cms/cms/urls.py"
from courses.admin import course_manager
urlpatterns = patterns('',
url(r'coursemanager/', include(course_manager.urls)),
url(r'^admin/', include(admin.site.urls)),
)
Then http://domain.local/coursemanager/ working properly and http://domain.local/admin panel is only listing all register admin but not showing the add/change links.
Upvotes: 1
Views: 307
Reputation: 23871
The app_name
of AdminSite()
is initialized through AdminSite.__init__()
. You cannot override it by providing class-level variable, thus you were experiencing instance namespace collision and then some reverse
failure, here, which caused add/change links not showing. Try
class CourseManager(AdminSite):
'...'
course_manager = CourseManager(name='CourseManager')
# or
course_manager = AdminSite(name='CourseManager')
Upvotes: 1