Closed eamonnfaherty closed 12 years ago
I have fixed this by changing the import in my main urls.py to
from longerusername.forms import AuthenticationForm as AuthenticationForm2
and by updating my urls.py entry to
(r'^accounts/login/$', 'django.contrib.auth.views.login', {'authentication_form': AuthenticationForm2}),
It may be worth updating the docs as this took me 3 hours to fix ;(
This shouldn't be an issue - I'm using it as-described. Are you importing another AuthenticationForm
? Alternately, can you paste the imports in your urls.py
?
I renamed the the imported form using the as keyword.
If I do not rename the form the validation fails.
I understand that. Can you paste your imports here? The only reason you should see the error you describe is if you're importing another AuthenticationForm
in your urls.py
.
My old import was
from longerusername.forms import AuthenticationForm
and it did not work.
My new import is
from longerusername.forms import AuthenticationForm as AuthenticationForm2
Can I suggest you change the docs import line to
from longerusername.forms import AuthenticationForm as LongerUsernameAuthenticationForm
This fixes the issue I encountered and makes the code more readable at least.
That's the only import in your entire urls.py file?
I can't replicate your issue at all, and as I mentioned, seems like it's a case where you've got something else importing AuthenticationForm
.
If you can provide a reproducible test case (skeleton app would be fine), I'd be happy to get this fixed.
I haven't got time to strip my code down to show an example. I am really sorry!
I think changing the docs isn't much work and the name I suggested improves the readability even if my bug didn't really exist.
I will post back here once my project is finished with an example.
thanks for your library!
Hey,
Yep, I get what you're saying, and I completely understand a time crunch - this library isn't my primary gig either, clearly.
The reason I want to reproduce what you're saying (instead of just changing the docs as you suggest) is that you should be able to just import it as AuthenticationForm
and have it just work. If that's not true, something is broken.
If the name change is needed, the form should be renamed in forms.py
. And even in that case, if your bug is generally true, something like this would break:
from longerusername.forms import LongerUsernameAuthenticationForm as AuthenticationForm
Which clearly, it should not.
That's why I haven't made the doc changes you suggest. Not because they don't fix the symptoms you see, but because I want to make sure that if there's a bug, it's fixed, so the library behaves properly.
Look forward to your example once you finish up. Thanks for keeping on this report!
-Steven
I installed the app as per instructions on the wiki and I am using a custom email backend.
I can login using the admin app no bother (both with username and email).
When I try to log in to my site through accounts/login it fails, saying that the username is longer than what is allowed.