T
T
toly2014-03-07 20:14:05
Django
toly, 2014-03-07 20:14:05

How to properly design a database with two or more user types in Django?

Hello.
The project uses two types of users: partner and client. Each user type has its own profile model: ClientProfile, PartnerProfile. The profile models are associated with the django.contrib.auth.User model, and a user cannot be both a client and a partner. Relationships of users with other models can be of three types:
- only client
- only partner
- client or partner
Connection of the type "client-or-partner" is present (so far) only once - in the comments.
Tell me, which models are better to use for "client only" and "partner only" relationships: the regular User model or profile models?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey K, 2014-03-08
@toly

Use the regular User model, write a validator to determine the type of connection.
In general, it's a bad idea to store profiles like this, it's better to store all the information in one profile or the user model itself, and define the user type through a special field.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question