1👍
✅
This validation is related to the form, and i think you should put this validation to the form.
You can add username to form data and pass it to the form.
For example,if username will be wrong, you can raise ValidationError
.
And others messages password short
and etc. seems to be validation errors, so should be in the form.
For example you pass request.POST
to the form.
You can do something like this:
data = request.POST.dict()
data['username'] = 'myusername'
form = Form(data)
And what is the problem to add username to the form as field, if you always need it?
Source:stackexchange.com