Search code examples
djangodjango-admindjango-authenticationdjango-authopenid

Value too long for type character varying(30)


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.


Solution

  • 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.