if django template language code example
Example 1: template tags in django
from django import template
register = template.Library()
#simle Tag
@register.simple_tag
def fun_name(data):
return data
Example 2: if condition in djangio template
{% if athlete_list %}
Number of athletes: {{ athlete_list|length }}
{% elif athlete_in_locker_room_list %}
Athletes should be out of the locker room soon!
{% else %}
No athletes.
{% endif %}