views:

37

answers:

1

I use a custom auth backend in my django application that allows users to login with ther emails.

But when I try to login in the admin I get the message: "usernames cant contain the '@' char"

I suppose this error is raised before it reaches the auth backend, so its a form issue, right ?

+1  A: 

Unfortunately no, this error is raised just if the authentication fails and there is no User with the given email. The bad thing is that this validation is hard-coded [1].

There is an open ticket for this [2].

Since version 1.2 django allows emails as User.username, if you're using this version maybe you won't even need a custom auth backend. But the bug [2] persists!

The only solution I can see to remove this validation is create a custom AdminSite and override the login() method, which is bad...

[1] http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/sites.py#L323 [2] http://code.djangoproject.com/ticket/13928

Igor Sobreira