Navigation in django
You do not need an if to do that, have a look at the following code: tags.py @register.simple_tag def active(request, pattern): import re if re.search(pattern, request.path): return ‘active’ return ” urls.py urlpatterns += patterns(”, (r’/$’, view_home_method, ‘home_url_name’), (r’/services/$’, view_services_method, ‘services_url_name’), (r’/contact/$’, view_contact_method, ‘contact_url_name’), ) base.html {% load tags %} {% url ‘home_url_name’ as home %} … Read more