Doesn't the UserManager already have a "normalize_email" method which lower-cases the domain and leaves the mailbox name alone?
IMHO It's "proper" to leave it this way by default, and probably mention in the docs it's used so if you want to change it, that's the hook. [We went through this recently with a client. They opted for all lower case but only because of legacy data.] -- Curtis On 27 February 2014 11:11, Russell Keith-Magee <russ...@keith-magee.com>wrote: > > This is a good point - I hadn't fully considered the issue of case in > email addresses. > > I agree that a case-insensitive index would be ideal; however, that's not > an option we have available across databases. > > Wim's suggestion to do case insensitive searches in forms, > get_by_natural_key etc sounds like the only option that would be available > to us. We could go the extra step to cleanse data on the way into the > database (e.g., forcing lowercase on save) but we can't guarantee that data > isn't finding it's way into the user table from other sources, so we > shouldn't rely on the fact that the database contains a "known to be in > lower case" representation. > > Yours, > Russ Magee %-) > > On Wed, Feb 26, 2014 at 9:06 PM, Wim Feijen <w...@go2people.nl> wrote: > >> Hi Tilman, >> >> Thanks for bringing this up. I lowercase my e-mail addresses every time - >> and when I forget I am wading through a pile of shit. (excusez le mot) >> >> Your solution looks neater, because it maintains user input. I have had >> users who used stefan.joos...@gmail.com once and later on: >> stefan.joos...@gmail.com to log in. (not using his actual name) >> >> In addition, we would need a proper form error when we try to create a >> user having a case-insensitive duplicate e-mail. >> >> Wim >> >> >> On Wednesday, 26 February 2014 09:39:53 UTC, Tilman Koschnick wrote: >>> >>> Hi Russell, >>> >>> On Wed, 2014-02-26 at 15:33 +0800, Russell Keith-Magee wrote: >>> >>> > The idea here is that we just ship a normal auth.User, but with email >>> > identification rather than username. >>> >>> I have just implemented an email based User model as well, and was >>> wondering about case sensitivity in the local part of the address. >>> >>> Most if not all final MTAs treat email addresses as case insensitive, >>> e.g. User.Name@... ist handled the same way as user.name@..., and some >>> users might not take care or notice of which form they used during >>> registration. A common recommendation is to preserve but subsequently >>> ignore case. >>> >>> I am handling this by using iexact lookups for users: >>> >>> def get_by_natural_key(self, username): >>> return self.get(email__iexact=username) >>> >>> In the database, uniqueness is enforced by an expression index: >>> >>> CREATE UNIQUE INDEX app_user_email_key ON app_user (upper(email)) >>> >>> I am not sure if DBMSs other than PostgreSQL support expression indexes; >>> either way, there is not Django support (yet). >>> >>> I don't know if this is of only theoretical concern, or a real world >>> issue - maybe others using email based users could share their >>> experience (my project is not deployed yet). >>> >>> Kind regards, Til >>> >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Django developers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-developers+unsubscr...@googlegroups.com. >> To post to this group, send email to django-developers@googlegroups.com. >> Visit this group at http://groups.google.com/group/django-developers. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-developers/fab46e55-7dad-4d7d-be55-ea13b606431d%40googlegroups.com >> . >> >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- > You received this message because you are subscribed to the Google Groups > "Django developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-developers+unsubscr...@googlegroups.com. > To post to this group, send email to django-developers@googlegroups.com. > Visit this group at http://groups.google.com/group/django-developers. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-developers/CAJxq84_b5eRzyCAp5erYvKir98ZRrpM80pxWLTiMOWgScxnRFw%40mail.gmail.com > . > > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Django developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAG_XiSDAYHzQfw%2BBr_roy%3D6%2Bjx1TN94gNvbhjXnPZZ_UCMJFDA%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.