I have a template tag that returns a date from a model field. If the date is today, I want to render some other content. Using the now builtin-templatetag: https://docs.djangoproject.com/en/1.11/ref/templates/builtins/#now, I used logic similar to the answer in this previously posted answer:
https://stackoverflow.com/a/34959070/5616606
{% now "Y-m-d" as todays %}
{% if self.date|date:"Y-m-d" == todays %}
...add some content
{% endif %}
I am trying to do this without creating a custom filter, context processor or edit the view. The problem, I believe, is with the timezone
. This works until later in the evening when now returns the next day, instead of the current day. I researched Django's date and timezone documentation but am not sure how make the timezone returned from now match the timezone of the model field without having to create a context processor or edit the view.