Django template - hide content based on time of day -
i want hide block in template (base.html) if time not weekday between 09:00 , 17:00.
i thinking (very simplified):
{% if 09:00 , 17:00 on weekdays %} #show callback form {% else %} #we not answer phone before 09:00 , after 17:00 {% endif %}
is possible?
i suggest creating flag in view.py
import datetime # in view = datetime.datetime.now() call_us_now = false if 9 < now.hour < 17: call_us_now = true # send 'call_us_now' context
.
{# in template #} {% if call_us_now %} {# show callback form #} {% else %} {# not answer phone before 09:00 , after 17:00 #} {% endif %]