500 内部服务器错误

500 INTERNAL SERVER ERROR tastypie

class SkyFileGroupPermissionResource(Resource):

    sky_file = fields.ForeignKey(SkyFileResource,'sky_file',null=False)
    group_id = fields.ForeignKey(SkyGroupResource,'group_id',null=False)
    expires_at = fields.DateTimeField(attribute='expires_at',null=False)
    cloud_url = fields.CharField(attribute='cloud_url')
    is_active = fields.BooleanField(attribute='is_active',default=False)
    new_devices_default_access = fields.BooleanField(attribute='new_devices_default_access',default=False)

    class Meta:
        queryset = SkyFileGroupPermission.objects.all()
        resource_name = 'file_group_permissions'
        authentication = ApiKeyAuthentication()
        authorization = DjangoAuthorization()
        allowed_methods = ['get','post','delete']

    def apply_authorization_limits(self,request,object_list):
        return object_list.filter(sky_file__storage__user=request.user.skyuser)

    def get_object_list(self,request):
        return super(SkyFileGroupPermissionResource,self).get_object_list(request).filter(sky_file__storage_user=request.user.skyuser)

为什么我在 GET 方法上得到 500 INTERNAL SERVER ERROR tastypie,我所有的 api 都工作正常,除了一个,它给我那个错误

这是回溯消息

Traceback (most recent call last):

  File "/home/gegham/django-tastypie/tastypie/resources.py", line 202, in wrapper
    response = callback(request, *args, **kwargs)

  File "/home/gegham/django-tastypie/tastypie/resources.py", line 433, in dispatch_list
    return self.dispatch('list', request, **kwargs)

  File "/home/gegham/django-tastypie/tastypie/resources.py", line 465, in dispatch
    response = method(request, **kwargs)

  File "/home/gegham/django-tastypie/tastypie/resources.py", line 1287, in get_list
    objects = self.obj_get_list(bundle=base_bundle, **self.remove_api_resource_names(kwargs))

  File "/home/gegham/django-tastypie/tastypie/resources.py", line 1097, in obj_get_list
    raise NotImplementedError()

NotImplementedError

你有什么想法吗,为什么会这样??

根据Tastypie documentationget_object_list()需要在用户级别实施。这意味着您不应在方法中调用 super()

但是,如果您要使用 ModelResource 而不是 Resource,那么 super() 将可供您使用。