Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3334800
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:56:42+00:00 2026-05-17T23:56:42+00:00

I have added a custom backend to allow a user to log in with

  • 0

I have added a custom backend to allow a user to log in with a username or email in addition to password. It works fine except when the email is longer than 30 characters. The form error I get is:

"Ensure this value has at most 30 characters (it has 35)."

In one my my apps’ urls.py file I’ve overridden the max_length of the username field like this:

from django.contrib.auth.forms import AuthenticationForm
AuthenticationForm.base_fields['username'].max_length = 75

I’ve even tried the class_prepared signal technique described here:

http://stackoverflow.com/questions/2610088/can-djangos-auth-user-username-be-varchar75-how-could-that-be-done/2613385#2613385

I’m not sure where I’m going wrong here and I appreciate the help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T23:56:43+00:00Added an answer on May 17, 2026 at 11:56 pm

    If your aim is to simply alter the length of the username field for the form (and not to alter the length of the username field in the database), then the correct solution is to subclass AuthenticationForm like so:

    from django import forms
    from django.contrib.auth.forms import AuthenticationForm
    
    class MyAuthenticationForm(AuthenticationForm):
        username = forms.CharField(label="Username", max_length=75)
    

    In fact, the docstring for AuthenticationForm even says “Base class for authenticating users. Extend this to get a form that accepts username/password logins.”

    Use your new form in place of the old AuthenticationForm in your templates, views, etc.

    As for why your code isn’t working, my guess is that your app’s urls.py isn’t being loaded before the AuthenticationForm is being imported elsewhere. I couldn’t swear to that being the reason, but it’s the most likely.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom window control (inherited from Window), all is fine except
I have added some custom actions to our installer which is run on CE5
I have created custom attributes for a category in my module's install script like
I have tried creating a syntax highlighter for a custom file definition. I get
I have created one library with Utility.h file. I want to add that custom
My view controller is not responding to didRotateFromInterfaceOrientation , despite that I have added
In my project I am using a custom circle-shaped button widget derived from the
I have created a sample application suing Application cache, My some files are located
Possible Duplicate: TFS 2010 Custom Build Activity TF215097 error I'm trying to create a
I am having trouble setting up VS2010 so I can debug in IIS: I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.