5👍
✅
You’ll have to detect if the request is for admin pages and skip what you want to in your context processor.
def my_context_processor(request,*args,**kwargs):
if 'admin' in request.META['PATH_INFO']:
return {}
else:
# do something here
9👍
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
- [Django]-Django 1.7 and smart, deep, filtered aggregations
- [Django]-Django 1.4 – Keeping track of multiple queries and pagination
- [Django]-Django app not found despite adding to INSTALLED_APPS?
- [Django]-Django queryset "contains" for lists, not strings
- [Django]-Records getting deleted from Mysql table automatically
Source:stackexchange.com