Django の Admin サイトを別でもう一つ作る

Posted by: ytyng 1 year, 4 months ago

Django の Admin を、/admin/ を残したまま別 URL を作りたい場合。

例: /staff/ で作る

1. staff/__init__.py

from django.contrib.admin import AdminSite
site = AdminSite(name='staff')


大元の urls.py

from staff import site as staff_site

...

url('^staff/', include(staff_site.urls)),

各モデルの Admin.py

from staff import site as staff_site

@admin.register
(MyModel)
@admin.register(MyModel, site=staff_site)
class MyModelAdmin(admin.ModelAdmin):
...
...
Currently unrated

Comments

Archive

2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011