Задать вопрос

Тел: +7 965 3737 888

406

Просмотров

2

Ответов

Case Insensitive Authentication Backend

<p>By enabling this backend:</p>
AUTHENTICATION_BACKENDS = (
    'path.to.my.backends.CaseInsensitiveModelBackend',
)

<p>Your users will now be able to log in with their username, no matter whether the letters are upper- or lower-case.</p>

Вопрос полезен? Да0/Нет0
file_2811.py(523.0б)
None

Ответы (2):

Ответbquinn:12.02.2014
Ответ полезен? Да0/Нет0

Since Django 1.5 (?) and pluggable user models, there's an alternative way to do this.

In the Manager for your user model, add a get_by_natural_key method, then you don't need to override the default auth backend.

class MyUserManager(BaseUserManager):
    def get_by_natural_key(self, username):
        return self.get(email__iexact=username)

Ответjohn_nash:27.04.2012
Ответ полезен? Да0/Нет0

where should i put this code .. !!