Why not create custom User model when creating a new project by default?

Hi! I’m new to Django and I’ve been pouring over the docs before I get started. I was reading through the docs about customizing the User model, and the documentation “highly recommends” (Customizing authentication in Django | Django documentation | Django) implementing a custom User model right when you start a new project, even if you don’t use it for anything.

I was wondering why the creation of a new Django project doesn’t set this up for you by default. Seems like a strange gotcha to have, since it could be a headache if you get started with the project and then realize you want to customize the User (say, email only instead of username).

It’s also a bit confusing to follow as someone new to all of the concepts in Django, to make sure that I’m doing everything right when setting this up.


There was a discussion recently and a pr to update the startproject template. It seems to have lost momentum. I would welcome the changes.

1 Like

I think this would be valuable and I’m sad to see the old PR stall as it did.

1 Like

Opened a new PR with just this change to hopefully help move it along. I’d appreciate any feedback on if I did it wrong, but this is the way that I understand the docs advise to do it: Fixed #27909 -- Add custom user model to project template by loganmac · Pull Request #17034 · django/django · GitHub

Just tossing out a random thought - take it for what it’s worth …

The first question that comes to mind is what app is that User model going to be created in? I’m not going to rehash the discussions regarding the naming of what is currently the “inner project-name directory”, but I don’t think that that would be the appropriate directory for that model.

As a result, my reaction to this is that this (creating an alternate User model) might more appropriately belong as an option in the startapp command and not in startproject.

Both are interesting points for sure! It’s a bit of a tricky problem because the Django project configuration is kind of a global thing as far as I understand it, and it asks you to point to a model that is a part of an app.

I didn’t understand when I first made this PR that the specified model has to be inside of an instantiated app, I was just following the instructions from the docs.

I wouldn’t think you’d want to do this as a part of every app you create, but I would think you would want it done for you correctly at least once per project.

I’ve been thinking on it some more, and it’s actually a tricky problem. Let’s say just for argument that we put it in a users app that we generate with the project. Ideally, we don’t re-invent the wheel with creating a new app, and we don’t just copy and paste all of that template code (which would now have to stay in sync with the app template), so it would be best to probably just have startproject create a users app by default and make sure it’s installed.

1 Like