Good afternoon, recently I have a problem in the Django framework, I have a problem in my custom template tag, I do the method in a .py file and I call it in templates and it does not display the result I want, can take a look please?
Follow the files:
time_tags.py
from django import template
from datetime import date
register = template.Library()
@register.filter
def informa_data(value):
today = date.today()
weekday = today.weekday()
if weekday == 4:
return str(today)
else:
return 'nao e sexta'
template.html:
Inserted {% load time_tags %}
just below:
{% extends 'base/base.html' %}
{% load staticfiles %}
And somewhere in the <body>
:
<p>
{{ instance.content|informa_data }}
</p>