【发布时间】:2014-09-18 15:58:16
【问题描述】:
我有这个工作代码可以从我在测试 url 使用普通 GET 请求测试的列表中过滤掉:
tag_list = request.GET.get('tag_list').split('&')
tags = Tag.objects.all()
all_species = Species.objects.all()
filtered_species = [all_species.filter(tags__description=c) for c in tag_list]
species = reduce(and_, filtered_species, all_species)
请求将如下所示:
/?tag_list=winged fruit&latex present&foo&bar
如何或在哪里将它作为自定义过滤器添加到我的 api 资源中?
【问题讨论】:
标签: python django rest tastypie