Removing case sensitivity from Email in Django login form

前端 未结 3 1228
旧时难觅i
旧时难觅i 2021-01-12 14:28

Before anyone marks it as duplicate, I\'ve searched everywhere and didn\'t find. I\'ve created a custom UserModel and used Email as main authenticating id instead of usernam

3条回答
  •  执念已碎
    2021-01-12 14:44

    When creating the account entry, interpret the email as email.lower() to create a normalised entry in your database.

    When parsing the email/username from a log in form, you should also use email.lower() to match the database entry.


    Note: the normalize_email only sanitises the domain portion of an email address:

    classmethod normalize_email(email)

    Normalizes email addresses by lowercasing the domain portion of the email address.

提交回复
热议问题