1👍
Very simple if-else clause here. Take a look at the django template docs to familiarize yourself with some of the common tags.
{% if value %}
APPLIED
{% else %}
NOT APPLIED
{% endif %}
You asked how to do this as a filter… I’m not sure why, but here is it:
In your app’s templatetags
directory create a file called my_tags.py
or something and make the contents
from django import template
register = template.Library()
@register.filter
def applied(value):
if value:
return 'Applied'
else:
return 'Not applied'
Then in your template make sure to have {% load my_tags %}
and use the filter with {{ value|applied }}
Source:stackexchange.com