Hi I have problem with intergration DRF and django-filters. How to display filters form in my HTML like in DRF API views. I was trying use @action decorator but that no works me. Someone have a idea how solve this problem ?
class AlbionViewsSets(viewsets.ModelViewSet):
queryset = Albion_data.objects.all()
serializer_class = Albion_data_Serializer
filterset_class = Itemfilters
lookup_field = "item"
filterset_class you are setting belongs to DjangoFilterBackend class, so in order to make it work, you have to set filter_backends field in your ViewSet. Most probably the following is what you want:
class AlbionViewsSets(viewsets.ModelViewSet):
queryset = Albion_data.objects.all()
serializer_class = Albion_data_Serializer
filter_backends = (DjangoFilterBackend,)
filterset_class = Itemfilters
lookup_field = "item"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.