Created
March 17, 2018 01:39
-
-
Save rg3915/f0cb92e1ac8a707bba8e1a881fb4c09f to your computer and use it in GitHub Desktop.
Form render with widget_tweaks and required fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- https://djangosnippets.org/snippets/474/ --> | |
{% load widget_tweaks %} | |
<style> | |
span.required:after { | |
content: "*"; | |
color: red; | |
} | |
</style> | |
{% for field in form.visible_fields %} | |
<div class="form-group{% if field.errors %} has-error {% endif %}"> | |
<label for="{{ field.id_for_label }}"> | |
{% if field.field.required %} | |
<span class="required">{{ field.label }} </span> | |
{% else %} | |
{{ field.label }} | |
{% endif %} | |
</label> | |
{% render_field field class="form-control" %} | |
{% for error in field.errors %} | |
<span class="text-muted">{{ error }}</span> | |
{% endfor %} | |
</div> | |
{% endfor %} |
Author
rg3915
commented
Feb 15, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment