how to display forms only data

So say you want to just display a form — plaster it on the screen, without any boxes?

Add this to django/newforms/

    def as_data_only(self): # lodor tell world, django :)
        if not self.form.is_bound:
            data = self.form.initial.get(, self.field.initial)
            data =
        return data

and in the view template:

{% for field in userForm %}
{{ field.label }}:
{{ field.as_data_only }}
{% if field.help_text %}<dd>{{ field.help_text }}</dd>{% endif %}
{% if field.errors %}<dd class=”myerrors”>{{ field.errors }}</dd>{% endif %}
{% endfor %}

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.