46👍
For email addresses, foo@bar.com
and foo@BAR.com
are equivalent; the domain part is case-insensitive according to the RFC specs. Normalizing means providing a canonical representation, so that any two equivalent email strings normalize to the same thing.
The comments on the Django method explain:
Normalize the email address by lowercasing the domain part of it.
8👍
One application of normalizing emails is to prevent multiple signups. If your application lets the public to sign up, your application might attract the "unkind" types, and they could attempt to sign up multiple times with the same email address by mixing symbols, upper and lower cases to make variants of the same email address.
From Django’s repository, the docstring of normalize_email
is the following:
Normalize the email address by lowercasing the domain part of it.
What this method does is to lowercase the domain part of an email, so this part is case insensitive, so consider the following examples:
>>> from django.contrib.auth.models import BaseUserManager
>>> BaseUserManager.normalize_email("user@example.com")
user@example.com
>>> BaseUserManager.normalize_email("user@EXAMPLE.COM")
user@example.com
>>> BaseUserManager.normalize_email("user@example.COM")
user@example.com
>>> BaseUserManager.normalize_email("user@EXAMPLE.com")
user@example.com
>>> BaseUserManager.normalize_email("user@ExAmPlE.CoM")
user@example.com
As you can see all emails are equivalent because the case after @
is irrelevant.
- [Django]-Django request.GET
- [Django]-Get name of primary field of Django model
- [Django]-Creating QuerySet object from last 7 days