[Fixed]-Django tastypie relative queryset

1👍

✅

You can override get_object_list

class ProjectResource(ModelResource):
    class Meta:
        queryset = Project.objects.all()
        resource_name = 'project'

    def get_object_list(self, request):
        qs = super().get_object_list(request)
        return qs.filter(creator=request.user)

    def authorized_read_list(self, object_list, bundle):
        return object_list.filter(creator=bundle.request.user.id)

Leave a comment