Search code examples
djangodjango-guardian

Is there a way to add "public" objects using django-guardian


I am using the great django-guardian to manage per object permissions on a project. In such project I will like all users be granted a permission (view, for instance) to all public objects.

As far as I know the only way to do this is granting each user the permission for each public object every-time an account is created.

Is there a better way such as leaving an object with a "wild card" permission or something similar. Is using a group the best?

Feedback is appreciated.


Solution

  • My recommendation is to assign all the users when created a group and provide access to the models with the default group in the definition of the model, as described here: https://django-guardian.readthedocs.org/en/v1.2/userguide/assign.html