Friday, December 19, 2014

Revisiting the case-sensitive login for the default user manager

Hello fellow Djangoers, I am new to the framework and just recently built a site using it.
However I was not aware of the username hurdle until just recently.
I did some research and found that I can make my own user manager and etc.

Now this is probably a bit of a hack, but tell me what you think.

I am on 1.6.5 and I did this:

from:

def get_by_natural_key(self, username):
        return self.get(**{self.model.USERNAME_FIELD: username})

to:

def get_by_natural_key(self, username):
        return self.get(username__iexact=username)

It works and does what I need it to do. How illegal is this and what potential problems can this create that I may not see now?

Thanks guys

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6dc608fc-7ddb-4e29-a2d0-f1d471766ab7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment