Django Rest Framework - AssertionError Fix your URL conf, or set the `.lookup_field` attribute on the view correctly
You need to override get_object()
, not get_queryset()
for detail views. You still want the permission checking so I suggest going through the source. First remove your get_queryset()
method then try this for starters:
# inside OrganisationDetail
queryset = Organisation.objects.all()
def get_object(self):
queryset = self.filter_queryset(self.get_queryset())
# make sure to catch 404's below
obj = queryset.get(pk=self.request.user.organisation_id)
self.check_object_permissions(self.request, obj)
return obj