Thursday, July 5, 2012

Re: insert html into a form from Django code (not template)

I've written a longer post here: http://stackoverflow.com/questions/11341118/printing-repeated-django-form-fields-individually explaining what I need. Either a way to individually print out the fields in a loop or a way to insert html from the backend. Maybe it's just not possible to do this in Django and then I will think of another solution, but I would like to make sure before I solve it another way.

/Angelika



On Thursday, July 5, 2012 12:53:32 PM UTC+2, stauros wrote:
On 07/05/2012 01:40 PM, Jon Black wrote:
/*SC*/DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"/*EC*/
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
May i suggest that the best way to do this is to create a template tag.
But i am not so sure about what she is trying to achieve.

--
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/-/T7hv5Ac62x4J.
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.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment