Like Ani said, There are different use cases. If you want to make a reusable app - that can be put up on pypi for example - then you shouldn't add a custom user model, but you can connect to the user model instead (this was previously recommended in django with the "UserProfile" solution).
However - if you are writing your own project - that you will be building on in the future, then the first thing I do is always to create a new user model. The reason for this is that it's hard to change that if you already have started writing your project and have a database in place and so on. Regards, Andréas Den tors 5 nov. 2020 kl 07:06 skrev ANi <[email protected]>: > Hi Thomas, > > The first one focuses on "project" and the second one focuses on "apps". > They don't contradict with each, a project may use many apps, they are > different. > If you want a reusable app then don't include a custom user model in it. > > Ani. > guettli 在 2020年11月4日 星期三上午2:59:37 [UTC+8] 的信中寫道: > >> Quoting the Docs >> <https://docs.djangoproject.com/en/3.1/topics/auth/customizing/#using-a-custom-user-model-when-starting-a-project> >> : >> >> *> If you’re starting a new project, it’s highly recommended to set up a >> custom user model, even if the default User >> <https://docs.djangoproject.com/en/3.1/ref/contrib/auth/#django.contrib.auth.models.User> >> model >> is sufficient for you. This model behaves identically to the default user >> model, but you’ll be able to customize it in the future if the need arises:* >> >> But this means: My code won't be reusable. >> >> Some lines below: >> >> *> Reusable apps shouldn’t implement a custom user model. A project may >> use many apps, and two reusable apps that implemented a custom user model >> couldn’t be used together. If you need to store per user information in >> your app, use a ForeignKey >> <https://docs.djangoproject.com/en/2.2/ref/models/fields/#django.db.models.ForeignKey> >> or OneToOneField >> <https://docs.djangoproject.com/en/2.2/ref/models/fields/#django.db.models.OneToOneField> >> to settings.AUTH_USER_MODEL as >> described below.* >> >> I think both sentences somehow contradict, since AFAIK it is highly >> recommended to >> write reusable apps. >> >> What do you recommend >> >> *reusable App XOR custom user model?* >> >> Regards, >> Thomas >> > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/93d808ff-00ac-46cc-8c4b-eb05002aec91n%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/93d808ff-00ac-46cc-8c4b-eb05002aec91n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK4qSCdvBKFkqUvDJW4kU31vkrpE-Zmvp3ybxPsh7jc9fOAA0Q%40mail.gmail.com.

