display the value of a django form field in a template Jul
06
1
2

Sometimes you need to get at the raw value of a field in a django form. This is easily done in 1.3 using the following:

{{ form.field_name.value }}

If you're running a version lower than 1.3 you can get at the value with:

{% if form.instance.field_name %}
{{ form.instance.field_name }}
{% else %}
{{ form.data.field_name }}
{% endif %}
Bookmark and Share
blog comments powered by Disqus