-1

I am developing an app which will have different types of users, and the objective is that in a specific Model, it is completed in a community way.

Example:

3 types of users: UserTotal, UserParcial, UserBase. Class object name ModelFamily, has 10 fields defined (int,char,date) I need all users to be able to see the class in the admin panel, but depending on which one I can only edit some fields.

How could I solve it? I don't have views at the moment, I'm managing everything from the Django Admin panel.

Thank you very much for your time!

I tried to change the permissions from admin but it is at Object level, not object field.

1 Answers1

0

To do this, I think the best approach is to use permissions.

Create a User model with a user_type field that indicates the type of user ("total", "partial", "base"). Then you could create a function to check the permissions of each user type, or use the built-in Permissions model.

Use the permissions to decide which fields in your model's form the current user should be able to see and update. You could use a if statement to determine the user's rights and only include form fields that the user is permitted to change.

Use the permissions system in your view function which manages form submission to limit which fields can be changed by each user type. You could, again, verify the user's permissions using an if statement and only allow the updating of certain fields if the user has the required permissions.

overclock
  • 585
  • 3
  • 20