I'm trying to use emails for usernames, and have got it working almost perfectly. I followed these directions: http://www.micahcarrick.com/django-email-authentication.html
The problem is, my login form still is throwing an error that says the username can only be 30 characters. I've changed the input form to accept 75 chars and the database table to as well. But something in Django is still blocking this.
Any ideas?
UPDATE:
<form method="post" action="." class="full">
{% csrf_token %}
<ul>
{% if form.non_field_errors %}<li>{{ form.non_field_errors }}</li>{% endif %}
<li>
{{ form.username.errors }}
<label for="id_username">Email/Username</label>
<input type="text" id="id_username" name="username" maxlength="75">
</li>
<li>
{{ form.password.errors }}
<label for="id_password">{{ form.password.label }}</label>
{{ form.password }}
</li>
</ul>
<input type="submit" value="Login">
<a href="{% url django.contrib.auth.views.password_reset %}">Forgot your password?</a>
</form>
In the end, I fixed this by adding this to my top level init
# Added so the login field can take email addresses longer than 30 characters
from django.contrib.auth.forms import AuthenticationForm
AuthenticationForm.base_fields['username'].max_length = 150
AuthenticationForm.base_fields['username'].widget.attrs['maxlength'] = 150
AuthenticationForm.base_fields['username'].validators[0].limit_value = 150
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With