How to filter WHERE , OR on django with serializer,model and view?

I’m making a request via GET with the following query:

site.org/mymodel?ordering=-created&state=awaiting_review

and I have updated to send with multiple states:

site.org/mymodel?ordering=-created&state=awaiting_review,phone_screened,interview_scheduled,interview_completed,offer_made,hired,rejected

But I have not found a doc in django that specifies how to treat it. So I’m not sure what to do right now. Maybe there is a vanilla option of how to do it.

The following codes are a mock of the current ones. What kind of function of part of django/python should I use to receive a filtered query with multiple values ?

the current one complains throwing this as response too.

{
  "state": [
    "Select a valid choice. awaiting_review,reviewed,phone_screened,interview_scheduled,interview_completed,offer_made,hired,rejected is not one of the available choices."
  ]
}

Should I change the URL too ?

Model.py: `

class MyModel():
    STATE_OPTIONS = (
        ("awaiting_review", "awaiting_review"),
        ("reviewed", "reviewed"),
        ("phone_screened", "phone_screened"),
        ("interview_scheduled", "interview_scheduled"),
        ("interview_completed", "interview_completed"),
        ("offer_made", "offer_made"),
        ("hired", "hired"),
        ("rejected", "rejected"),
    )

    state = models.CharField(
        max_length=19, choices=STATE_OPTIONS, default="awaiting_review", null=False
    )

Serializer.py:

class ASerializer(serializers.ModelSerializer):
    class Meta:
        model = MyModel
        fields = ( state )
`

view.py: `

class MyModelView(generics.ListAPIView, ProtectedResourceView):
    serializer_class = ASerializer
    filter_fields = ("state")
    ordering_fields = ("state")

    def get_queryset(self):
        return MyModel.objects.filter(user=self.request.user).filter(
        something_thats_not_state = self.request.query_params.get("something_thats_not_state")
        )

`

Wanted to do something like “WHERE ( something = 1 OR something = 2 OR something = 3 )”
but with drf, didn’t find nothing close to it.

You use this library GitHub - philipn/django-rest-framework-filters: Better filtering for Django REST Framework

I use django-filter to solve something like this. In particular, the IN filter works well for filtering across multiple values for a choice field.

https://django-filter.readthedocs.io/en/stable/
https://django-filter.readthedocs.io/en/stable/ref/filters.html#baseinfilter