6

so i have seen a lot of solutions but i found most answers for older versions of Django and i was wondering if there are any changes on that.

Basically i am using Django 1.7, and i wanted to override the uusername field in the default django USER class to allow more than 30 chars i.e max_length=75.

Should i be using AbstractBaseUser instead or is there an easier way to put max_length=75

psychok7
  • 5,373
  • 9
  • 63
  • 101
  • `username` length got increased in django 1.10 to 150 chars (https://docs.djangoproject.com/en/1.10/releases/1.10/#abstractuser-username-max-length-increased-to-150). If that's still not enough, they recommend you to use a custom user model (info copied from AndreiPetre). – jjmontes Sep 08 '16 at 11:51

1 Answers1

3

Yeah I think you are going to have to go down the custom user route.

You can take a look here for some inspiration https://github.com/jcugat/django-custom-user that package implements contrib.auth.User except with no username and just using email. You can probably work out how to do what you want from there.

A similar question was posted where a user detailed a very hacky work around but it might get you by in a pinch: Longer username in Django 1.7

Community
  • 1
  • 1
xxx
  • 1,465
  • 1
  • 14
  • 23
  • i see, well until there is a better approach im marking your answer as the correct one :) – psychok7 Jan 12 '15 at 09:49
  • Thanks a lot, out of interest what is the need for longer usernames? – xxx Jan 12 '15 at 11:45
  • i had a use case where the username should be equal do the email. We ended up changing that use case and are "ignoring" the username (using Uuid) because it too late now in the project to be altering/extending Auth User – psychok7 Jan 12 '15 at 12:37
  • Yeah I thought that might be the issue, that package I linked to would be a cleaner solution but I'm not sure what (if anything) it would break either. – xxx Jan 12 '15 at 13:32