Re: iterating through form.fields
On Sun, Mar 22, 2009 at 5:09 AM, Yaniv Haberwrote: > > 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? > What version of Django are you using? The doc notes that visible_fields and hidden_fields are new in development, so they are only going to be available if you are using a recent trunk checkout or the 1.1 alpha release. Karen --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: iterating through form.fields
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 Rosemanwrote: > On Mar 22, 8:20 am, nivhab 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 %} > > > > {{ field.errors }} > > {{ field.label_tag }}: {{ field }} > > > > {% 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 -~--~~~~--~~--~--~---
Re: iterating through form.fields
On Mar 22, 8:20 am, nivhabwrote: > 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 %} > > {{ field.errors }} > {{ field.label_tag }}: {{ field }} > > {% 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-form-s-fields -- 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 -~--~~~~--~~--~--~---