title: How to reproduce native template date formatting with value_to_string in Django
body: <p>I am trying to write a module which allows me to specify which fields should be displayed in a <code>FieldList</code> directly in the model, in order to be able to use generic template for all the models.</p>
  
  <p>So, in the template for the generic list, I don't know what fields have to be displayed. Using templatetags (I know, it's a bit ugly), I am finally able to display the list with the corresponding values, but I have to use the function <code>value_to_string</code>, as described here :</p>
  
  <pre><code>@register.simple_tag
  def get_value_field(instance, field):
      """
      Returns the value of a field for an instance.
      """
      return field.value_to_string(instance)
  </code></pre>
  
  <p>And in the template :</p>
  
  <pre><code>{% with object_list|get_list_fields as field_list %}
      [...]
          {% for field in field_list %}
          &lt;td&gt; {% get_value_field object field %} &lt;/td&gt;
          {% endfor %}
  </code></pre>
  
  <p>Everything is working, except that I don't understand why <code>value_to_string</code> (which uses <code>isoformat()</code>, see <a href="http://fossies.org/dox/Django-1.6.5/django_2db_2models_2fields_2____init_____8py_source.html#l00806" rel="nofollow">http://fossies.org/dox/Django-1.6.5/django_2db_2models_2fields_2____init_____8py_source.html#l00806</a>) and the default template formatting behave differently, as <code>{{ object.date_begin }}</code> displays "11 août 2014" (I'm French) although the <code>{% get_value_field object field %}</code> gives me the <code>isoformat()</code> "2014-08-11".</p>
  
  <p>What am I doing wrong ?</p>
  
  <p>I may use the following code to get the python date and then format it, but I am sure there is a better way to do this.</p>
  
  <pre><code>@register.simple_tag
  def get_value_field(instance, field):
      """
      Returns the value of a field for an instance.
      """
  
      # Cas particuliers pour l'affichage
      if isinstance(field, django.db.models.fields.DateField):
          return field._get_val_from_obj(instance).[...] # Format date to the same format here
  
      return field.value_to_string(instance)
  </code></pre>