The meaning of null=True and blank=True in the model also depends on how these fields were defined in the form class.
Suppose you have defined the following class:
class Client (models.Model):
name = models.CharField (max_length=100, blank=True)
address = models.CharField (max_length=100, blank=False)
If the form class has been defined like this:
class ClientForm (ModelForm):
class Meta:
model = Client
fields = ['name', 'address']
widgets = {
'name': forms.TextInput (attrs = {'class': 'form-control form-control-sm'}),
'address': forms.TextInput (attrs = {'class': 'form-control form-control-sm'})
}
Then, the 'name' field will not be mandatory (due to the blank=True in the model) and the 'address' field will be mandatory (due to the blank=False in the model).
However, if the ClientForm class has been defined like this:
class ClientForm (ModelForm):
class Meta:
model = Client
fields = ['name', 'address']
name = forms.CharField (
widget = forms.TextInput (attrs = {'class': 'form-control form-control-sm'}),
)
address = forms.CharField (
widget = forms.TextInput (attrs = {'class': 'form-control form-control-sm'}),
)
Then, both fields ('name' and 'address') will be mandatory, "since fields defined declaratively are left as-is" (https://docs.djangoproject.com/en/3.0/topics/forms/modelforms/), i.e. the default for the 'required' attribute of the form field is True and this will require that the fields 'name' and 'address' are filled, even if, in the model, the field has been set to blank=True.