I need the request.path in my template tag. But the problem is, my django version is 1.5.1 and I dont have the TEMPLATE_CONTEXT_PROCESSORS
, so there's no django.core.context_processors.request
. Now, its giving me the error:
Exception Type: AttributeError
Exception Value:'str' object has no attribute 'path'
Exception Location:C:\Users\Nanyoo\web\pics\album\templatetags\active_tags.py in active, line 8
Is there any other way to get the desired path in the template?
views.py:
def home(request):
photos = Photo.objects.all()
return render(request,"index.html", {'photos':photos})
active_tags.py:
from django import template
register = template.Library()
@register.simple_tag
def active(request, pattern):
import re
if re.search(pattern, request.path):
return 'active'
return ''