A
A
Alexander Bondarenko2021-03-07 12:33:10
Django
Alexander Bondarenko, 2021-03-07 12:33:10

How to correctly establish a relationship between a user group and a database model?

I have two user groups Students and teachers, I created a Group model, and there should be a 1xM connection between the group and students, but how to do this with a group of students. I have this idea:
Create a separate model, inherit from User and add a group there, etc.
When registering, drop it into Students and immediately into the role of a student, when changing the role to a teacher, delete it from students
How much it has the right to life, and maybe there are options it is better?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2021-03-07
@bond_1013

django already has https://docs.djangoproject.com/en/3.1/topics/auth/... you can use them

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question