I wish to make some modifications to the Django admin interface (specifically, remove the "change" link, while leaving the Model name as a link to the page for changes to the instances). I can achieve this by copying and pasting index.html from the admin application, and making the modifications to the template, but I would prefer to only override the offending section by extending the template - however I am unsure how to achieve this as the templates have the same name. I am also open to alternative methods of achieving this effect. (django 1.7, python 3.4.1)
Worked it out - I set admin.site.index_template = "my_index.html"
in admin.py, and then the my_index template can inherit from admin/index.html without a name clash.
Might be cleaner to override the index_template for AdminSite:
from django.contrib.admin.sites import AdminSite
AdminSite.index_template = '...'
Though again, that might be made more external-code-friendly by either: changing this on a custom instance before binding, or subclassing a custom AdminSite and overriding there, and registering that custom AdminSite instead.
Relevant documentation:
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#root-and-login-templates
Edit: To clarify - this would allow you to just override the section you're changing in the template, and so inherit any upstream changes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With