S
S
Sergey Protasov2019-08-22 15:39:05
Django
Sergey Protasov, 2019-08-22 15:39:05

How to add a user to the child model if it exists in the parent?

1. There is a common user model.
2. There is a model

class Driver(get_user_model()):
    ...

If we add a user to the Driver model, then it is automatically added to the get_user_model() model.
If the user is in get_user_model() but not in Driver, how can I add it to Driver?
The Driver model has additional fields that are not needed in get_user_model().

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Guest007, 2019-08-22
@protasovse

It's better not to inherit, but to add a OneToOne related model. Lots of examples of how to implement user profiles. Here is the same thing. They can be linked differently in this way. Then the user's essence (for login - that's it) is one in any case, and all additional fields are in one-to-one linked models.
And no duplication!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question