include_maybe.py 313 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from django import template
from django.template.defaultfilters import stringfilter


register = template.Library()


@register.filter
@stringfilter
def template_exists(value):
    try:
        template.loader.get_template(value)
        return True
    except template.TemplateDoesNotExist:
        return False