Can django handle multiple users with the same username?

I mean using the default django authentication backend and functions.

If two users have the same usernames but different passwords is django able to login that user and return the correct User object? Or is the authenticate function not able to handle that scenario? I looked in the github and I don't think the username field in the User model has to be unique


Short answer: no.

Long answer: Django doesn't support having more than one user with the same username because, even with what you are proposing (password differentiation) there is still a chance two users will have the same password. Even if it weren't like this, I find it very hard to find a reason to let users share their usernames. You can create an "alias" or something additional, and let it be "not unique"

链接地址: http://www.djcxy.com/p/33692.html

上一篇: 使用JWT Auth进行LDAP服务验证

下一篇: django可以使用相同的用户名处理多个用户吗?