Hello,
Issue : I would like to compare date at year level only. Idea is to
display the year only once if the two date are within the same year.
I have the following model :
class Training(models.Model):
who = models.ForeignKey(User, verbose_name='Person')
title = models.CharField('Name', maxlength=100)
description = models.TextField('Description', blank=True)
start_date = models.DateField('Start date',)
end_date = models.DateField('End date', blank=True, null=True)
and the following template :
{% for training in user_training %}
{# TODO : Fix date if start_date = end_date at year level #}
<li>{{ training.start_date|date:"Y" }} {% ifequal
training.start_date training.end_date %} {% else %} {% if
training.end_date %}- {{ training.end_date|date:"Y" }}{% endif %} {%
endifequal %} : {{ training.title }} {% if training.description %}: {{
training.description }}{% endif %}</li>
{% endfor %}
I tried with adding |date:"Y" in a ifequal condition but it looks it's
not sufficient
Either it does not go into the else section. Same with a ifnotequal and
reversing the logic.
Any idea?
Nicolas
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---