Instantly share code, notes, and snippets.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import template | |
from django.core.urlresolvers import reverse | |
def do_if_active_url(parser, token): | |
try: | |
tag_name, request, urls = token.split_contents() | |
except ValueError: | |
raise template.TemplateSyntaxError, ("%r tag requires exactly two arguments, received" % | |
token.contents.split()[0], len(token.contents.split()[0])) | |
if not (urls[0] == urls[-1] and urls[0] in ('"', "'")): |