title: How to compare dates in Django templates
body: <p>I would like to compare a date to the current date in Django, preferably in the template, but it is also possible to do before rendering the template. If the date has already passed, I want to say "In the past" while if it is in the future, I want to give the date.</p>
  
  <p>I was hoping one could do something like this:</p>
  
  <pre><code>{% if listing.date &lt;= now %} 
       In the past 
  {% else %} 
       {{ listing.date|date:"d M Y" }} 
  {% endif %}
  </code></pre>
  
  <p>With now being today's date, but this does not work. I couldn't find anything about this in the Django docs. Can anyone give some advice?</p>