On Monday, April 25, 2011 9:16:18 PM UTC+1, lingrlongr wrote: > > I have a view that subclasses uses django.views.generic UpdateView. > In my template, I'm trying to access a form field's required > property. For example: > > {% for field in form %} > {{ field.required }} > {% endfor %} > > Nothing outputs when the template is rendered. Does the "required" > attribute not get populated when using the class-based UpdateView > generic view? I'm assuming that is correct, just looking for > confirmation as to yes, it's supposed to work like that. Any reason > why this would not be an included attribute? > > These documentation for the new class-based views seems very vague > ATM. > > Keith
Forms work exactly the same in class-based views as they do in any other views. However you're using the form, the `required` attribute is not on the `field` object you get when doing `for field in forms`. It is, perhaps confusingly, on the field's `field` property, so you need to do {{ field.field.required }}. -- 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.