Thanks for answering! I would really like to do it that way, if I could. But I only want the html for some of the fields, not all of them. It would be great if I could iterate over just a few fields or be able to generate the name of the field in a loop, something like this:
[some fields] {% for index in count|get_range %} <p>Some stuff I want here that form.as_p won't do for me</p> <div class="fieldWrapper"> {{ field_name_[somehow get index in here].errors }} {{ field_name_[somehow get index in here] }} </div> <div class="fieldWrapper"> {{ field_email_[somehow get index in here].errors }} {{ field_email_[somehow get index in here] }} </div> {% endfor %} [some more fields] but I can't figure out a way to add index as a part of the field name. On Thursday, July 5, 2012 12:40:57 PM UTC+2, Jon Black wrote: > > I've never done this, so I'm just throwing out ideas to try and be > helpful. I've found your stackoverflow post as well, which has more > information. ( > http://stackoverflow.com/questions/11341118/printing-repeated-django-form-fields-individually > ) > > Have you tried looping over the fields in the template? I know this is in > the template, but you can add the text you want still: > > > {% for field in form %} > <p>Some stuff I want here that form.as_p won't do for me</p> <div > class="fieldWrapper"> > {{ field.errors }} > {{ field.label_tag }}: {{ field }} > </div>{% endfor %} > > -- > Jon Black > www.jonblack.org > > > On Thu, Jul 5, 2012, at 03:20, angelika wrote: > > Thanks, but I am asking if there is a way to insert html into a form from > the backend code, and not in the template? > > On Thursday, July 5, 2012 11:57:57 AM UTC+2, angelika wrote: > > Is there a way to insert arbitrary html into a form from the Django code, > and not in the template? The equivalent of #markup in a Drupal form. > > /Angelika > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/y7Inar5KaoEJ. > 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. > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/c4XoyWzaL4QJ. 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.