Django REST Permissions on Nested Routes -



Django REST Permissions on Nested Routes -

i using django rest framework nested router extension. 1 of routes looks like: companies/$company/locations/$location $company , $location slug variables.

i want allow users post url: companies/$company/locations/ add together new locations. want create sure user doing post has correction permissions company posting to. utilize django-guardian object level permissions. post message contains name of new location not contain name of company can inferred url. having hard time correctly enforcing permissions in case. had been setting company field of new location object viewset's pre_save method late permission check applied.

what best way enforce this?

in case there user include company in post, can validate company adding next viewset:

def get_queryset(self): parent = super(locationviewset, self).get_queryset() homecoming parent.filter(company__slug=self.kwargs['company_slug'])

django django-rest-framework nested-routes django-guardian

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -