from apis.betterself.v1.events.serializers import SupplementEventSerializer
from apis.betterself.v1.utils.views import BaseGenericListCreateAPIViewV1
from events.models import SupplementEvent


class SupplementEventView(BaseGenericListCreateAPIViewV1):
    serializer_class = SupplementEventSerializer
    model = SupplementEvent

from apis.betterself.v1.events.serializers import SupplementEventSerializer
from apis.betterself.v1.utils.views import BaseGenericListCreateAPIViewV1
from events.models import SupplementEvent


class SupplementEventView(BaseGenericListCreateAPIViewV1):
    serializer_class = SupplementEventSerializer
    model = SupplementEvent

    def get_queryset(self):
        name = self.request.query_params.get('name')
        if name:
            queryset = self.model.objects.filter(name__iexact=name)
        else:
            queryset = self.model.objects.all()

        return queryset

Add queryset, but debate if better options
Add queryset, but debate if better options

  from apis.betterself.v1.events.serializers import SupplementEventSerializer
  from apis.betterself.v1.utils.views import BaseGenericListCreateAPIViewV1
  from events.models import SupplementEvent
  
  
  class SupplementEventView(BaseGenericListCreateAPIViewV1):
      serializer_class = SupplementEventSerializer
      model = SupplementEvent
  
+     def get_queryset(self):
+         name = self.request.query_params.get('name')
+         if name:
+             queryset = self.model.objects.filter(name__iexact=name)
+         else:
+             queryset = self.model.objects.all()
+ 
+         return queryset
+ 
Add queryset, but debate if better options
## Code Before:
from apis.betterself.v1.events.serializers import SupplementEventSerializer
from apis.betterself.v1.utils.views import BaseGenericListCreateAPIViewV1
from events.models import SupplementEvent


class SupplementEventView(BaseGenericListCreateAPIViewV1):
    serializer_class = SupplementEventSerializer
    model = SupplementEvent

## Instruction:
Add queryset, but debate if better options
## Code After:
from apis.betterself.v1.events.serializers import SupplementEventSerializer
from apis.betterself.v1.utils.views import BaseGenericListCreateAPIViewV1
from events.models import SupplementEvent


class SupplementEventView(BaseGenericListCreateAPIViewV1):
    serializer_class = SupplementEventSerializer
    model = SupplementEvent

    def get_queryset(self):
        name = self.request.query_params.get('name')
        if name:
            queryset = self.model.objects.filter(name__iexact=name)
        else:
            queryset = self.model.objects.all()

        return queryset
