match filter

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
import re

from django import template

register = template.Library()

@register.filter
def match(value, regex):
    """Usage: {% if value|match:"regex" %}"""
    return re.match(regex, value)

Comments

(Forgotten your password?)