Boolean Image Flag TemplateTag

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Put this in your custom templatetags file

@register.inclusion_tag('app/boolean_flag_img.html')
def boolean_img(flag):
    return {'flag': flag}

# Use as your 'boolean_flag_img.html' file
{% if flag %}
<img src="/media/icons/accept.png" alt="True" />
{% else %}
<img src="/media/icons/deny.png" alt="False" />
{% endif %}

More like this

  1. Template filters utils by marinho 6 years, 5 months ago
  2. email_links by sansmojo 6 years, 10 months ago
  3. Serializing booleans correctly when doing dumpdata from a MySQL database using Django 0.96 by chrj 5 years, 8 months ago
  4. Safe template decorator by eternicode 1 year, 11 months ago
  5. Paginator TemplateTag by trbs 6 years ago

Comments

(Forgotten your password?)