-2

I have an app with multiple users from different companies.

I need to restrict access such that certain users from certain companies can only see model objets relevant to their company.

For e.g. when I display a drop-down in a template, I want the dropdown contents to be different for each user based on their predefined permissions.

I am not a developer so I may be reading the Django documentation poorly, but if I were to guess it doesn't seem possible.

If indeed it is not straight forward via Django built-ins, is there any clever workaround?

gmarais
  • 1,801
  • 4
  • 16
  • 32
  • Here is exactly what I was trying to do https://stackoverflow.com/questions/3010489/how-do-i-filter-values-in-a-django-form-using-modelform – gmarais Nov 10 '20 at 14:59

1 Answers1

-1

It is not a big deal , If you have spent some time to do this than you may have some progress, I want to see that progress, If you didn't start work on this. Than i can tell you the simple path to make it done.

Step 1: first you have to make models one for company , other one for user and third one for that certain conditions.

Step 2: After these model you can make their fields , where user have a many to many relation with conditions model,

Step 3: After this you can make migrations , and register all the models in the admin.py ,

Step 4: Add some conditions manually in the conditions models and select some condition from some random user,

Step 5 : Add condition on template where you want to show the drop down manu , and add condition by if request.user.condition in user.condition than show what ever you want.

Ahmed Yasin
  • 886
  • 1
  • 7
  • 31