Firstly, it is not a question of how to authenticate by email / password, but rather how to create a logical and, if you like, beautiful data structure.
I want to use emails as usernames in this django project. However, I cannot reuse the fields provided by the auth.User model for at least two reasons:
The auth.User.username max_length field is 30 characters, which may not be enough for some email addresses.
auth.User.email is not unique - which is clearly not satisfactory for the premise that usernames must be unique.
Thus, the obvious way is to save the username in a custom profile that is associated with auth.User. In this case, we are dealing with the following problems:
- Create a unique username for auth.User.username - should the md5 email hash be okay?
- Leave auth.User.email empty completely - since it contains only 75 characters, and in accordance with RFC 5321 ( What is the maximum length of a valid email address? ) It can be up to 256 characters long.
The following problems arise from the proposed solution:
- One of them will not be able to reuse the built-in views / templates for standard operations such as password reset, etc.
- If you change the email, auth.User.username will need to be updated.
To add oil to the fire, django developers are unlikely to fix this limitation in the foreseeable future - see http://code.djangoproject.com/ticket/11365 p>
So the question is: is there another way to do this, and you see any other flaws in the solution proposed above?
Thanks!
database django data-structures architecture
Art
source share