I
I
Irina Pakhomova2015-10-23 23:51:06
Django
Irina Pakhomova, 2015-10-23 23:51:06

How to display error messages in a template?

I'm trying to write a registration on the site based on the built-in UserCreationForm. I want to do such an obvious thing as displaying a message to the user that the passwords do not match. And I don't understand how to do it. There, in this case, a ValidationError is raised in the form, and I don’t understand what to do with it.
I looked in Google, in the documentation, but I can not find anything. I probably don't look there. Even annoying, like some kind of nonsense.
I'm just starting to learn django if that :)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Ovdienko, 2015-10-29
@doubledare

There is a standard battery, by default it is already connected django.contrib.message
You
can collect errors in the view in message.error
and display in the template as message.error

A
Alexander Lebedev, 2015-10-23
@zymanch

Validation on the server is fundamental?
Why drive data to the server and back, if this is how you can do everything quickly and cheaply on the frontend.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question