Thanks. It works that way although the examples in the documentation
also show iterating through form.visible_fields which result in
nothing. This is where I came from. Any idea why that happens?


On Mar 22, 10:44 am, Daniel Roseman <roseman.dan...@googlemail.com>
wrote:
> On Mar 22, 8:20 am, nivhab <yaniv.ha...@gmail.com> wrote:
>
>
>
> > Hi,
>
> > I have this problem which is probably right in front of my eyes but I
> > just cannot get it. Maybe someone can point me in the right direction:
>
> > I am trying to iterate through form.fields in a template.
> > The form is rather simple:
>
> > class ProductForm(forms.Form):
> >     name = forms.CharField(max_length=200)
> >     description = forms.CharField(max_length=200)
> >     url = forms.URLField('Product URL Page', verify_exists=True,
> > required=False)
>
> > Iteration in template (standard):
>
> >     {% for field in form.fields %}
> >         <div class="fieldWrapper">
> >             {{ field.errors }}
> >             {{ field.label_tag }}: {{ field }}
> >         </div>
> >     {% endfor %}
>
> > The result of this code is EMPTY text.
> > However, the following code which reference specific fields:
>
> >  {{ form.name.label_tag}}: {{ form.name }}
>
> > (and every other field I reference) renders the expected html without
> > any issue.
>
> > Any hints why this is happening?
>
> > Thanks, Yaniv
>
> Don't loop through form.fields - as the documentation shows, you
> should loop through 
> form.http://docs.djangoproject.com/en/dev/topics/forms/#looping-over-the-f...
> --
> DR.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to