提供的资源查找数据无效

时间:2013-07-08 08:00:08

标签: tastypie

资源定义,网址覆盖和自定义方法:

class LocationResource(ModelResource):
    create_by = fields.OneToOneField('frittie.app.api.api.UserResource', 'create_by', null=True, blank=True)
    follow_by = fields.ToManyField('frittie.app.api.api.UserResource', 'follow_by', null=True, blank=True)

    class Meta:
        queryset = Location.objects.all()
        resource_name = 'Location'
        allowed_methods = ['get','post','put','delete']
        serializer = Serializer(formats=['json', 'plist'])
        # authorization= DjangoAuthorization()

        def override_urls(self):
            return [
                url(r"^(?P<resource_name>%s)/(?P<%s>[\w/-]*[\w-])%s$/follow_by%s$" % (self._meta.resource_name, trailing_slash()), self.wrap_view('get_follow'), name="api_get_follow"),
            ]

        def obj_create(self, bundle, request=None, **kwargs):
            username, email, password = bundle.data['username'], bundle.data['password'], bundle.data['password'], 
            try:
                bundle.obj = User.objects.create_user(username, email, password)
            except IntegrityError:
                raise BadRequest('That username already exists')
            return bundle

        def get_follow(self, request, **kwargs):  
            basic_bundle = self.build_bundle(request=request)  
            obj = self.cached_obj_get(bundle=basic_bundle,   **self.remove_api_resource_names(kwargs))  
            user_resource = UserResource()  
            return user_resource.get_list(request, location =obj )  

我试图打开此链接,但它保留:

"error_message":Invalid resource lookup data   provided (mismatched type).  
localhost/api/frittie/Location/1/follow_by/?username=itams&  api_key=42cc8665811e121edbbd57ceee90c1373da2f60  

任何人都可以告诉我api实现中有哪些错误

0 个答案:

没有答案