1👍
✅
The popup that you see for the email it is not django validation. It is the build in in-browser html5 email field checking (and some older browsers will not do it for you).
And you can’t get any kind of validation in html5, but for checking field presents you can add required
attribute to the rendered input field.
There are several ways to add attibutes to widgets in django. take a look to the How do I get Django forms to show the html required attribute? and select appropriate for you.
0👍
kmmbvnr directed me to what I was looking for. To add the type of validation I was looking for, add code similar to that below:
class UserForm(forms.ModelForm):
...
username = forms.CharField(
widget=forms.TextInput(attrs={'required': 'true'}),#HERE
)
password = forms.CharField(
widget=forms.PasswordInput(attrs={'required': 'true'}),#OR HERE
)
...
- Passing data through render to template
- How to put a django form on a bootstrap modal with another form on the same page (outside the modal)?
Source:stackexchange.com