How to override and extend basic Django admin templates?

前端 未结 11 1039
长发绾君心
长发绾君心 2020-11-22 14:11

How do I override an admin template (e.g. admin/index.html) while at the same time extending it (see https://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-vs-r

11条回答
  •  庸人自扰
    2020-11-22 14:46

    for app index add this line to somewhere common py file like url.py

    admin.site.index_template = 'admin/custom_index.html'
    

    for app module index : add this line to admin.py

    admin.AdminSite.app_index_template = "servers/servers-home.html"
    

    for change list : add this line to admin class:

    change_list_template = "servers/servers_changelist.html"
    

    for app module form template : add this line to your admin class

    change_form_template = "servers/server_changeform.html"
    

    etc. and find other in same admin's module classes

提交回复
热议问题