Email as username, case sensitive email address

I use email address as username in Django app

USERNAME_FIELD = 'email', but the email field is case sensitive, therefore:

test@example.comand test@example.comsaved as two different users. Is this normal or do I need to check it somehow?

+6
source share
2 answers

You should check both email addresses as one user and always try to save the username in lowercase.

If you save both email addresses as different users, there are some problems that need to be handled manually, and this increases overhead.

  • , test@example.com Caps, .
  • username, iexact, icontains .
+2

, , , ..

def save(self, *args, **kwargs):
    self.email = self.email.lower()
    return super(User, self).save(*args, **kwargs)
+1

All Articles