我使用的是django-rest-framework和https://github.com/alex/django-filter/,但问题主要是关于django-filter.我无法理解如何使用"__in"查找过滤器.
例如,我有模型:
class Book(models.Model):
name = models.CharField(max_length=100)
class BookView(viewsets.ReadOnlyModelViewSet):
serializer_class = BookSerializer()
model = Book
filter_fields = ('id', 'name')
Run Code Online (Sandbox Code Playgroud)
我不能像这样使用网址
/ V1 /书籍/?id__in = 1,2,3
找到id为1,2或3的书籍