[Answered ]-How to set blank=False in Django form without a Model

1👍

I’m going to point out @Daniel Roseman’s comment above – don’t use this form for saving passwords, at least not how you’re doing it. For other forms though: You want required, not blank. Blank is for models, required is for forms.

class LoginForm(forms.Form):
    username=forms.CharField(label="Username",max_length=30,required=False)
    password=forms.CharField(label="Password",widget=forms.PasswordInput(),required=False)

1👍

use required=True instead of blank=False

e.g:

username=forms.CharField(label="Username",max_length=30,required=True)

In Django, blank=False in models correlates to required=True in forms.

Leave a comment