Mohamed Feddad

47%
Flag icon
# app/templatetags/nav.py from django.core.urlresolvers import resolve from django.template import Library   register = Library() @register.simple_tag def active_nav(request, url):     url_name = resolve(request.path).url_name     if url_name == url:         return "active"     return ""
Mohamed Feddad
Setting a custom template tag
Django Design Patterns and Best Practices: Industry-standard web development techniques and solutions using Python, 2nd Edition
Rate this book
Clear rating