Since it seems that users are allowed to use their usernames to login instead of only email, I want to make the user name default to the email address. How do I achieve this? I'm assuming that I have to override the model somewhere.
Asked
Active
Viewed 53 times
1 Answers
0
Its simple. While you create the User Object, why don't you refer the username to the email..
user = User.objects.create(
username = mail,
email = mail
)
this will do..

Aswin Murugesh
- 10,831
- 10
- 40
- 69
-
I'm looking for an answer in the context of Satchmo. I'm not sure where this behavior is defined and where the proper place to override the default behavior is. The docs only talk about custom payment and product modules, so I'm not really sure if we're able to change this. Perhaps I should mention that the default behavior maps the username to the email user without any symbols, and if it's already taken, to the user's first and last name (haven't tested beyond that). – Lunyx Jan 16 '14 at 22:13
-
Investigated some more and determined that the model is writing to auth_user table upon registration. – Lunyx Jan 16 '14 at 22:19
-
@Daniel: this is used when upon registration the auth_user object is created – Aswin Murugesh Jan 17 '14 at 03:09
-
Am I supposed to overwrite the view that creates this then? – Lunyx Jan 17 '14 at 03:34
-
@Daniel: yes. You would have created the user object when the user registers right? Put this code in the creation view instead of the original one you are using – Aswin Murugesh Jan 17 '14 at 03:37
-
No, I did not create it. It's predefined somewhere. Looking at the satchmo docs, it does not seem to be defined there. Maybe it's defined by django.registration.. – Lunyx Jan 17 '14 at 07:47