Reputation: 1919
for some reason I need to have two different instances of Django Admin Site in my project - default admin site and an instance of class inheriting from AdminSite.
So I created a class MyAdminSite(AdminSite)
Then I wrote something like:
my_admin_site = MyAdminSIte(name='myadmin')
Then I added proper entry in urls.py.
Everything works fine.
But now i want to customize some templates.
In settings.py:
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
TEMPLATE_DIRS = (os.path.join(BASE_DIR, 'templates'),)
Then I created directories:
/PROJECTDIR/templates/admin
and /PROJECTDIR/templates/myadmin
The thing is, I simply cannot extend/override templates in 'myadmin' django admin site. For example, if I add, let's say an empty 'base_site.html' into /templates/admin/, then both admin sites becomes blank.
But when I add same file into /templates/myadmin/, nothing happenes.
Any tips?
Upvotes: 2
Views: 760
Reputation: 122466
You can override class variables of AdminSite
to specify different templates:
app_index_template = None
login_template = None
logout_template = None
password_change_template = None
password_change_done_template = None
You can also override class variables of ModelAdmin
to specify different templates:
add_form_template = None
change_form_template = None
change_list_template = None
delete_confirmation_template = None
delete_selected_confirmation_template = None
object_history_template = None
For example:
class MyAdminSite(AdminSite):
app_index_template = "my/new/admin/app_index.html"
Upvotes: 1