Search code examples
djangodjango-authenticationdjango-users

Worried about the use of built in django auth system set to emails, knock on effects


I set django default user authentication to use an email address instead of a user name.

My worry is about the possible future effects. If the user changes his email will the primary keys need to be changed as I assume the primary key for a user is now an email. What are the basic consequences of this.

The users will also have their own space on the website, hence the urls will need to have some kind of username/unique identification ,I do not foresee an issue here as but if you do please advise.

My main concern being updates of email causing bugs in the database and application.

I know the topic is broad but what would the consequence be here or are there none.

Thank you.


Solution

  • The username is unique, but it is not the primary key. Django creates a primary key id by default. See the docs on automatic primary key fields for more information.

    So you should be able to change your username or email without causing problems with primary keys.

    However, if you include the username or email address in the url, then these would of course change if the user changes their details.