<commit_before>from django.conf import settings



def django_admin(request):
    '''
    Adds the variable boolean django_admin to context indicating whether the current 
    page is part of the django admin or not.
    '''
    
    
    
    if settings.ADMIN_URL.endswith('/'):
        admin_url = ''.join(settings.ADMIN_URL[:-1])
    if not settings.ADMIN_URL.startswith('/'):
        admin_url = '/' + settings.ADMIN_URL
    
    data = {
        'ADMIN_URL': admin_url
    }
    
    if request.META['PATH_INFO'].startswith(admin_url):
        data['django_admin'] = True
    else:
        data['django_admin'] = False
        <commit_msg>fixed issue considering a '/' admin_url; added comments;<commit_after>from django.conf import settings



def django_admin(request):
    '''
    Adds the variable boolean django_admin to context indicating whether the current 
    page is part of the django admin or not.
    
    REMEMBER: do not set ADMIN_URL='/' in case your application features functionality
    outside of django admin; otherwise all incoming urls are interpreted as admin urls.
    '''
    # ensure that adminurl always starts with a '/' but never ends with a '/'
    if settings.ADMIN_URL.endswith('/'):
        admin_url = ''.join(settings.ADMIN_URL[:-1])
    if not settings.ADMIN_URL.startswith('/'):
        admin_url = '/' + settings.ADMIN_URL
    
    # add ADMIN_URL to context
    data = {'ADMIN_URL': admin_url}
       
    if request.user.is_staff and request.META['PATH_INFO'].startswith(admin_url):
        # only set django_admin in case the user is staff and the
        # current url starts with the admin url.
        data['django_admin'] = True
    else:
        data['django_admin'] = False
    
{'fraction_non_alphanumeric': 0.09867282169648009, 'fraction_numerical': 0.001154068090017311, 'mean_word_length': 2.729032258064516, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4736463', 'n_tokens_mistral': 513, 'n_tokens_neox': 501, 'n_words': 156}