Debian Codegraph @

favicon/templatetags/favtags.py

raw
1 from django import template
2 from django.core.cache import cache
3 from django.utils.safestring import mark_safe
4
5 from favicon.models import Favicon
6
7 register = template.Library()
8
9
10 @register.simple_tag(takes_context=True)
11 def place_favicon(context):
12 """
13 Gets Favicon-URL for the Model.
14
15 Template Syntax:
16
17 {% place_favicon %}
18
19 """
20
21 fav = Favicon.on_site.filter(isFavicon=True).first()
22 if not fav:
23 return mark_safe('<!-- no favicon -->')
24
25 html = fav.as_html()
26 return mark_safe(html)