Search code examples
pythondjangodjango-allauth

how does django-allauth generate the username?


I'm using django-allauth and have enabled auto signup but I'm not sure how id decides on the username to use.

for example I just tested the auto signup with my Facebook account

my Facebook username is davidgriver

my Facebook first and last name are David Griver

django-allauth signed me up automatically under the username ddd

can someone explain to me why that happened and how I can make it either take the Facebook username or if that's not possible take the first and last name make them lowercase and remove the space

the google one is a bit smarter, it just takes the first name, but that's pretty bad because first names are common and not unique at all.

Ideally with google I would like to just take whatever is before the @ symbol and use that.


Solution

  • allauth generates unique usernames by using generate_unique_username method defined in utils.py. Here is the link