Answer the question
In order to leave comments, you need to log in
Django + Vue.js What is the best way to make a shape variation?
Good day.
Tell me, please, the correct/adequate/use-case version of the form validation. Input: Django model with multiple fields, reactivity via Vue.js. There are many fields that are mutually exclusive and depend on the user's previous selection, but they are required fields (in each of the selections). I hide them from the form on the front, with v-if
(and the Flatpickr fields with v-show
) attribute.
So, if you do validation through Django (or rather, don’t do it, but use the built-in one), then such fields will not be validated (logically), since they have blank=True
. Otherwise, on the field hidden in this way, Django will swear, but the error will not be displayed - in fact the field is not in the DOM.
On the other hand, giving all the validation to the front will work, but it’s somehow scary.
I'll be glad for good advice!
Answer the question
In order to leave comments, you need to log in
I did both types of validation myself, since my username and captcha are also checked for presence. That is, in vue I do validation on required, phone format, password match and complexity, min length. On django, that such a user is not registered, captcha, left the required check. The form is checked by ajax, I display errors from django in the same place where I display vue errors.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question