Shawn, He wants the form attribute to be applied to the div, not the field.
Andreas, You can't pass an attribute to a field and expect it to show up in a different object altogether. I assume your div isn't handled by django, so you need to fix that first in order to be able to pass extra attributes to it. A few solutions: 1) Use a fieldset (like the admin does) and then define how *that* gets rendered - complex, flexible. 2) Pass a css attribute to the view (not sure where you're going to get that css_class stuff from) and use it in your template's context, then add classes on the fly during template compilation - easy, ugly. Cheers, André On Wed, Jul 13, 2011 at 3:25 PM, Shawn Milochik <sh...@milochik.com> wrote: > On 07/13/2011 02:00 PM, Andreas Pfrengle wrote: > >> Hello Shawn, >> >> thanks for your answer, however that's not exactly what I wanted. Now >> the html renders to: >> <label for="id_n_properties">No. of properties</label> >> <input value="4" type="text" name="n_properties" div_css="test" >> id="id_n_properties" /> >> >> However, I would want: >> <div class="test"> >> <label for="id_n_properties">No. of properties</label> >> <input value="4" type="text" name="n_properties" >> id="id_n_properties" /> >> </div> >> >> Additionally, I can't access {{ field.widget.attrs.div_css }} to get >> the class directly, I get an empty string instead. >> >> > Replace 'div_css' in my example with 'class' and you'll get 'class="test"' > in your output. > > > > -- > 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+unsubscribe@** > googlegroups.com <django-users%2bunsubscr...@googlegroups.com>. > For more options, visit this group at http://groups.google.com/** > group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en> > . > > -- 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.