I'm trying to follow the full example at the bottom of
https://docs.djangoproject.com/en/dev/topics/auth/customizing/
In my model I have modified to the following
date_of_birth = models.DateField(null=True)
However when I try register a user I still get the following error message:
date_of_birth <ul class="errorlist"><li>This field is required.</li></ul>
In what other places do I need to make date_of_birth optional?
Use null=True and blank=True in your model.
A Python optional argument is a type of argument with a default value. You can assign an optional argument using the assignment operator in a function definition or using the Python **kwargs statement. There are two types of arguments a Python function can accept: positional and optional.
You would have to add blank=True
as well in field definition.
date_of_birth = models.DateField(null=True, blank=True)
From modelform doc
If the model field has blank=True, then required is set to False on the form field. Otherwise, required=True.
Don't forget to reset and sync DB again after changing this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With