Issue
By default _form.as._p spits out:
<p><label for="id_subject">Subject:</label>
<input id="id_subject" type="text" name="subject" maxlength="100" /></p>
Whereas I need
<p><label for="id_subject">Subject:</label><p>
<input id="id_subject" type="text" name="subject" maxlength="100" /></p>
with a break between the label and the input. How can I modify my Django code to do so?
Solution
You simply just can't use form.as_p
anymore. If the defaults don't work for you, then you must render the fields manually:
<form action="/contact/" method="post">
{% for field in form %}
<div class="fieldWrapper">
{{ field.errors }}
{{ field.label_tag }}: {{ field }}
</div>
{% endfor %}
<p><input type="submit" value="Send message" /></p>
</form>
See the docs: https://docs.djangoproject.com/en/dev/topics/forms/#looping-over-the-form-s-fields
Answered By - Chris Pratt
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.