I have a sign up form which asks only for email and password. When a user signs up, django-allauth creates a username for that user by striping the "@email" suffix form the user's email address.
So for example, if a user signs up with "[email protected]" his username will be "some-user" and if another user signs up with "[email protected]" then his username will be "some-userr"
But what I want is the username and email of the users to have the same value.
So how can I configure django-allauth to set the usernames as the users emails without striping their suffixes?
And if possible, how can I do that without creating a custom user.
In my settings.py:
#########################
# AllAuth Configuration #
#########################
ACCOUNT_AUTHENTICATION_METHOD = 'email'
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
ACCOUNT_PASSWORD_MIN_LENGTH = 8
from allauth.socialaccount.adapter import DefaultSocialAccountAdapter
class CustomSocialAccountAdapter(DefaultSocialAccountAdapter):
def populate_user(self, request, sociallogin, data):
user = super().populate_user(request, sociallogin, data)
user.username = user.email
return user
SOCIALACCOUNT_ADAPTER = "profiles.models.CustomSocialAccountAdapter"
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