2
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 call it in the templates and does not display the result I want, can take a look doing 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'
html template.:
Inseri {% load time_tags %}
just below the:
{% extends 'base/base.html' %}
{% load staticfiles %}
And somewhere within the <body>
:
<p>
{{ instance.content|informa_data }}
</p>
Dude, the error in your code is not fixed with this code that you put there in the answer. You abandoned the use of your custom template tag instead of fixing it. I found this a little strange, because they had already indicated where was the error of their custom template tag in another reply.
– Henrique Marti