61
Thanks, i found, right settings for my task:
ACCOUNT_AUTHENTICATION_METHOD = 'email'
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_USERNAME_REQUIRED = False
48
If you encounter the error django.core.exceptions.FieldDoesNotExist: Account has no field named 'username'
with reference to USER_MODEL_USERNAME_FIELD
in the stacktrace, you’ll also need to set ACCOUNT_USER_MODEL_USERNAME_FIELD
to None
(or the appropriate field for your use case). The full set of settings needed are the following:
ACCOUNT_AUTHENTICATION_METHOD = 'email'
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_USER_MODEL_USERNAME_FIELD = None
ACCOUNT_USERNAME_REQUIRED = False
This setting is explained in more detail in the django-allauth documentation for Custom User Models with defaults outlined in Configuration.
- [Django]-Cross domain at axios
- [Django]-Django and query string parameters
- [Django]-Django and fieldsets on ModelForm
2
A probable cause could be any of the following for a custom user model;
a) if you’ve totally eliminated "Username" as a field in your model, then, do ensure that in your model, you define the variable:
USERNAME_FIELD = 'email'
Also, do ensure that in the field definition of email, the field attribute;
unique = True
is as well included.
b) In your custom User admin (which must be compulsorily configured), the form and add_form variables must be defined to inherit from "ModelForm" or UserCreationForm (for the add_form variable).
c) if you’re inheriting allauth’s Signup Form, then, you’ll have to declare in your settings:
ACCOUNT_USER_MODEL_USERNAME_FILED = None
Most importantly, ensure you write tests to ensure that form posts data and saves to the database. Thanks. Hope someone finds this helpful….. Remember, it can only be hard, but never impossible!!! Happy ‘Djangoing’….
- [Django]-How to assign items inside a Model object with Django?
- [Django]-Serving large files ( with high loads ) in Django
- [Django]-How to run gunicorn from a folder that is not the django project folder