2👍
✅
The ModelAdmin
class has various template settings that you can specify in subclasses. In Django 1.3 these are (at django.contrib.admin.options
, line 271):
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
Similarly, AdminSite
has various template settings (at django.contrib.admin.sites
, line 35):
index_template = None
app_index_template = None
login_template = None
logout_template = None
password_change_template = None
password_change_done_template = None
You can override these for subclasses or specify them in a central location in your code (e.g., a __init__.py
file). For example:
from django.contrib.admin.sites import AdminSite
AdminSite.index_template = '...'
You can then vary the templates based on the current Django version. You may need to check what the code looks like in earlier Django versions as I haven’t checked if all these variables are present in earlier Django admin code.
Source:stackexchange.com