Reputation: 2770
I'm getting this error message on my email field
but i'm using the built in django auth system
. Is there an easy way to override it. When the user registers the email address is added into the built in field within the built in user system.
Would be great if it's possible to make it extend it over 30 chars due to the nature of the site.
Upvotes: 3
Views: 4484
Reputation: 143
Maybe it is not right way, but in my project i just increased user email size with south. Sample:
>> ./manage.py schemamigration auth --initial && ./manage migrate auth --fake
Then i added into models.py:
from django.contrib.auth.models import User
field = User._meta.get_field('email')
field.max_length = 254
field = User._meta.get_field('username')
field.max_length = 254
Now:
>> ./manage.py schemamigration auth --auto
>> ./manage.py migrate auth
Upvotes: 2
Reputation: 10197
That is one of the issues with using email addresses for user names in Django. Many, many emails are over 30-characters. One common way to address this issues is using a custom "Authentication Backend" for email authentication. Using your own backend you can authenticate a user based on the email
field instead of the username
field. You can then generate the username based on that email address or using random generated usernames.
You can read more about this approach on my blog post Django Authentication using an Email Address.
Upvotes: 3