Django user creation

Background - Hello, I am very new to django / python stack. I am trying to work on a website that needs custom user so I have inherited AbstractUser class to make my own custom user model, I am using Django built in authentication - log in / sign up as well and am able to do this successfully and store it and retrieve back in MySql database.

Now my problem - I need to create users that can be tied as a family as this will be for a gym. So once user logs in they can see all members of family and book separate classes etc for each member also clicking on each member needs to pull in their profile information etc.

I have tried to search but couldn’t find specific answer yet so posting - is groups a way or what? If anyone can point me to right direction please ?

Hello there!
Are you also new to relational databases?
If not, do you know how would you represent this relationship on a relational database?

Yes I am new to relational databases as well

I suggest that you also add this to your list then, it’s really important to know it.
I will try to explain it how do I view this approach, not that this is the only way of doing it, neither the best one.

id (integer)
name (varchar)

id (integer)
... other fields
family_id (FK int)

With this relationship, you can now track all of the users from the same family (users that have the same id on the family_id).
It will be up to you how to control this, for example, you can have a unique “PIN” for each family that users can submit when they sign-up in order to join a family, or when they sign-up if they don’t provide a family, then create one for it.

Once you understand how your data model is going to be, it would be easier to translate it to a django-model.

1 Like