【发布时间】:2013-11-11 12:15:48
【问题描述】:
我在 DjangoAuthorization 方法中使用 sweetpie。
我有一个这样的 StudentResource:
class StudentResource(ModelResource):
friends = fields.ToManyField(StudentResource, 'friends', null=True)
class Meta:
queryset = Student.objects.all()
resource_name = 'student'
authorization = DjangoAuthorization()
所以我的每个学生都有很多朋友。
现在,我想返回,当我的用户只对他的朋友进行 API 调用时。 (基于他的 django id)。 (我不想只是在我的资源中添加过滤器,我真的希望用户只能访问他的朋友)
我可以使用 get_list sweetpie 函数覆盖 GET 方法,但它看起来很丑。
那么有什么好的方法呢?
谢谢!
【问题讨论】:
标签: python django filtering tastypie