from rest_framework import viewsets
from django_filters import filters, filterset

from api.v09.views import ResultsSetPagination

from ..models import CandidateResult, ResultSet
from ..serializers import CandidateResultSerializer, ResultSetSerializer


class CandidateResultViewSet(viewsets.ModelViewSet):
    queryset = CandidateResult.objects.select_related(
        "membership__party", "membership__post", "membership__person"
    ).order_by("id")
    serializer_class = CandidateResultSerializer
    pagination_class = ResultsSetPagination


class ProductFilter(filterset.FilterSet):
    election_id = filters.CharFilter(name="post_election__election__slug")
    election_date = filters.DateFilter(
        name="post_election__election__election_date"
    )

    class Meta:
        model = ResultSet
        fields = ["election_date", "election_id"]


class ResultSetViewSet(viewsets.ModelViewSet):
    queryset = ResultSet.objects.select_related(
        "post_election__post", "user"
    ).order_by("id")
    serializer_class = ResultSetSerializer
    pagination_class = ResultsSetPagination

    filter_class = ProductFilter

@@ -547,22 +547,24 @@
 %0A%0Aclass 
-Produc
+ResultSe
 tFilter(
@@ -622,16 +622,22 @@
 rFilter(
+field_
 name=%22po
@@ -706,24 +706,24 @@
 Filter(%0A
-
         
 name=%22po
@@ -714,16 +714,22 @@
         
+field_
 name=%22po
@@ -1133,14 +1133,16 @@
 s = 
-Produc
+ResultSe
 tFil

Update filter args and fix name