Search code examples
pythondjangodjango-modelsuser-permissionsdjango-users

Django, more type of user - I need advice


I need advice. I want to make 3 types of user:

  1. member (only nickname/password/email)
  2. company (nickname/password/email/company/regon + permision for edit model)
  3. admin

My question is about how to make model for these users:

  1. make big model for member and company together but field which are only for comapny make empty for member. Next to by admin panel i can make group and add "comapny" ppl

  2. make 2 type of user (here i will need advice like what i should use on it) and seperate website register for member and company and login should be the same form.


Solution

  • You can achieve this simply by creating a Boolean field for each type of user (member, company, admin) in your User model. Save the different type of users from different URLs, when save just change the Boolean flag into True. Then, you can handle the user in view like if user_type.member: and so on. It also can be achieved by using Enum (choice) field.