Below, I have this div that is responsible to show any error, warning and success message. But I figure out how to use it with the success case only.
This is my views.py
def registration(request):
form = PersonForm(request.POST or None)
if form.is_valid():
save_it = form.save(commit=False)
save_it.save()
messages.success(request, 'Your form was saved')
<if checkbox not checked> <<< is this possible ?
messages.error(request, 'You must accept the terms to register')
return render(request, 'provisioning/registration.html', {'form':form,})
And this is my registration.py
<div>
...
{% if messages %}
{% for message in messages %}
<div {% if message.tags %} class="alert alert-{{ message.tags }}" {% endif %} alert-danger fade in">
<button data-dismiss="alert" class="close close-sm" type="button">
<i class="fa fa-times"></i>
</button>
<strong>{{ message.tags }} | </strong> {{message}}
</div>
{% endfor %}
{% endif %}
</div>
My question is: how can I validate my fields and show if everything went fine or not in my html page ?
For example, there is a checkbox for the agreement of terms of use, right ? How can I use the messages to tell to the user that he need to accept the terms of use to register in case if wasn't checked by the user.