How to change the username requirements?

Hi all,
I want to be able to change the requirements for the username ideally without making a custom user. Furthermore I want to change the text that is displayed by the user creation form to match my requirements. The username needs to be the full name of the user and therefore the user needs to be able to input spaces.

It would be great if someone could help me out!

You can’t do that without having a custom user model, because you’d have to override the validators on the model field.

But why does the username need to be the full name of the user? That’s what first_name and last_name (or perhaps full_name on a custom user model) are for.

1 Like

I am currently reworking my school’s website and the old site required that the username is their fullname. I could probably work round this with first_name, last_name but I still need to copy over all the old users which all have spaces in their names.
As an info the old website was build with php.

Django’s first name + last name setup exists solely out of historic reasons. Any newly build user model would go for a name or full_name field. While we all know that naming things is hard, storing people’s names is even harder to do.

@freakboy3742 gave a very enlightening talk “Red user blue user” about this topic back in 2013and again in 2017: https://m.youtube.com/watch?v=458KmAKq0bQ

The way forward is using a custom user model. In fact, I think the Django documentation even recommends to add a custom user model at the beginning of every project, just to avoid a possibility migration from the built-in to your own down the line.

Thanks for your help! I will now read up on custom user models and try build one that fits my needs.