How can I exclude Django django-admin pages for my custom templates context processor?
Following up on Dhiraj’s answer, which works if your system uses the default (English/non-translated) URLs, and for the sake of those us who do use localised URLs, I found the following snippet to do the trick in the easiest manner (relevant to Django 1.10 and later, not tested on earlier versions).
from django.urls import reverse
if request.path.startswith(reverse('admin:index')):
return {}
else:
# do stuff relevant to non-admin pages
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