graphene-django-extras icon indicating copy to clipboard operation
graphene-django-extras copied to clipboard

How to filter QuerySet in DjangoSerializerType ?

Open kentuck13 opened this issue 3 years ago • 0 comments

I have articles. Each user must be read only their own articles. -> Articles.objects.filter(user=request.user)


class ArticleModelType(DjangoSerializerType):
    class Meta:
        filter_fields = {
            'name': ['exact'],
            'category': ['exact'],
            'category__name': ['exact']
        }
        serializer_class = ArticleSerializer

class Query(graphene.ObjectType):
    article, articles = ArticleModelType.QueryFields()

I still haven't found a place where I should put this QuerySet = Articles.objects.filter(user=request.user)

kentuck13 avatar Feb 25 '21 12:02 kentuck13