Open jdrempel opened 3 years ago
Hey buddy, have you already solved?
If not, you can create specific statements on access policy class with conditions to each action, or make a if-else statement where get_object
is called according to the action, or refactor your code to remove quiz
where isn't being used, among other similar solutions.
Hi there.
I'm using
view.get_object()
as shown in the documentation but in certain cases there is an assertion failing (lookup_url_kwarg in self.kwargs
) inside ofget_object()
. In the example I share here, it's on the list action, where the url follows the pattern:/quiz/?course=<pk>
. In another case, however, it's when I use the create action on a different model.Expected view QuizViewSet to be called with a URL keyword argument named "pk". Fix your URL conf, or set the .lookup_field attribute on the view correctly.
Here is my policy:
The condition methods:
So clearly I'm missing the
pk
but I'm not exactly sure how I'm supposed to provide that. Any ideas?