Ahh, thanks Scott. That's very helpful. On Aug 23, 6:18 am, Scott Gould <zinck...@gmail.com> wrote: > You can refer to individual fields by name, for example: > > > <div class="my_custom_html"> > > {% form.first_name %} > > </div> > > Looping through them works fine for simple forms but as you say, if > you want something more elaborate in your template, you sometimes need > to go field-by-field. > > What I do is write an inclusion tag with all the markup I want for my > fields, automatic outputting of css classes matching the widget type > so I can style them, etc. and then pass the field as the argument: > > {% my_inclusion_tag form.first_name %} > > On Aug 22, 10:47 pm, orokusaki <flashdesign...@gmail.com> wrote: > > > Normally, I would do something like this: > > > {% for field in form.fields %} > > <div class="my_custom_html"> > > {% field %} > > </div> > > {% endfor %} > > > What if I need: > > > <div class="my_custom_html"> > > {% one field %} > > </div> > > > <div class="some_other_custom_html"> > > <h2>Some Title</h2> > > <div class="even_more_stuff"> > > {% another field %} > > </div> > > </div> > > > I want to be able to still use model forms and I don't want to hard > > code {% if field == "email" %}Custom Stuff{% endif %}. Is there a good > > way to do this, or a convention that I can use to ensure that my HTML > > won't stop working when I update Django (I know that there is the > > id_field_name convention, but I'm looking for a little more insight if > > anyone out there does this alot.
-- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.