title: Convert string to date django template
body: <p>I'm trying to convert string to date in template using template tag but it doesn't work</p>
  
  <pre><code>{% load templat_tag_file %}  
  &lt;input name="range2" type="date" {% if request.GET.range2 %}
  value="{{ request.GET.range2|convert_str_date }}"{% endif %}/&gt;
  </code></pre>
  
  <p>my templat_tag_file.py :</p>
  
  <pre><code>from datetime import datetime
  register = template.Library()
  @register.filter
  def convert_str_date(value):
      return datetime.strptime(value, '%Y-%m-%d').date()
  </code></pre>
  
  <p>I got this error: time data '' does not match format '%Y-%m-%d'</p>