Hi

I have been using this patch to get around the short user name (which is 30 
characters):

#--------------------------------------------------------------------------
#
# Patch to allow username to exceed the default maximum of 30 characters
#
# http://stackoverflow.com/a/6453368/1228131
#
# Note: this works for django 1.3, 1.4, 1.5, 1.6
#

# Import what we need
from django.contrib.auth.models import User
from django.core.validators import MaxLengthValidator

# New username length
NEW_USERNAME_MAX_LENGTH = 75

# Method to patch the user name maximum length
def monkey_patch_username_maximum_length():
    
    username = User._meta.get_field("username")
    username.max_length = NEW_USERNAME_MAX_LENGTH

    for validator in username.validators:
        if isinstance(validator, MaxLengthValidator):
            validator.limit_value = NEW_USERNAME_MAX_LENGTH

# Patch the user name maximum length
monkey_patch_username_maximum_length()

#--------------------------------------------------------------------------


> On Mar 22, 2015, at 10:55 AM, Tim Graham <timogra...@gmail.com> wrote:
> 
> Currently you need to use a custom user model if you want to change the 
> username max_length. There's an open ticket to increase the default length to 
> 254 though: https://code.djangoproject.com/ticket/20846
> 
> On Sunday, March 22, 2015 at 10:45:34 AM UTC-4, somen...@gmail.com wrote:
> Thanks, Anderson, but can I overwrite the length of User class? How? Sorry 
> I'm still a newbee? With AbstractUser? 
> [https://docs.djangoproject.com/en/1.7/topics/auth/customizing/#django.contrib.auth.models.CustomUser]
>  or Extending user class 
> [https://docs.djangoproject.com/en/1.7/topics/auth/customizing/#extending-the-existing-user-model]?
> 
> On the other, hand, it were useful if someone could add the information in 
> the web page.
> 
> El diumenge, 22 març de 2015 15:28:34 UTC+1, Anderson Resende va escriure:
> No, the user class uses 75. You need to change to 254.
> 
> models.EmailField(max_lenght=254)
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/012b584e-3e72-44e6-9a09-4909b2b3353c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/C9304BDE-FD41-48A6-93C1-119751D48267%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to