18👍
✅
If you can’t pass them in directly (which would be preferable), they are available on the request object:
company_id = request.resolver_match.kwargs.get('company_id')
request.resolver_match.args
and request.resolver_match.kwargs
contain the positional/keyword arguments captured in your url.
👤knbk
8👍
As an alternative to the correct response posted by knbk, you can also get the URL parameters using the view object passed to has_permission method. Like this:
company_id = view.kwargs.get(‘company_id’)
Source:stackexchange.com