Template filters utils

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from django.template import Library

register = Library()

@register.filter
def multiple_of(value,arg):
    return value % arg == 0

@register.filter
def in_list(value,arg):
    return value in arg

@register.filter
def is_equal(value,arg):
    return value == arg

@register.filter
def is_not_equal(value,arg):
    return value != arg

@register.filter
def is_lt(value,arg):
    return int(value) < int(arg)

@register.filter
def is_lte(value,arg):
    return int(value) <= int(arg)

@register.filter
def is_gt(value,arg):
    return int(value) > int(arg)

@register.filter
def is_gte(value,arg):
    return int(value) >= int(arg)

More like this

  1. Date/time util template filters by marinho 6 years, 5 months ago
  2. Template filter that divides a list into exact columns by davmuz 2 years, 3 months ago
  3. Tags & filters for rendering search results by exogen 6 years ago
  4. A simple rest template filter by marinho 6 years, 5 months ago
  5. typygmentdown by ubernostrum 6 years, 8 months ago

Comments

(Forgotten your password?)