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.

Reply via email to