Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable django context processor in django-admin pages

How can I exclude Django django-admin pages for my custom templates context processor?

like image 386
Paul Avatar asked Dec 09 '25 19:12

Paul


1 Answers

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
like image 84
interDist Avatar answered Dec 11 '25 13:12

interDist



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!