Answer the question
In order to leave comments, you need to log in
How to pull data by URI (DRF)?
Who knows how to get data by uri ?
There is a table in the database and the uri is stored in it: "api/v1/myapp?my_filter=my_value" . I came up with a crutch way, send a GET request and receive data.
Is it possible to feed a ModelViewSet with yuriai and get the data? Or feed the FilterSet with yuriai and get the data?
Answer the question
In order to leave comments, you need to log in
from django.http import QueryDict
my_obj = MyFilterSet(data=QueryDict("status=show&count=10"), queryset=MyModel.objects.all()).qs
I think it was meant
from urllib import parse
from django.urls import resolve
uri = '/api/v1/myapp?my_filter=my_value'
data = parse.urlsplit(uri)
path = data.path
params = dict(parse.parse_qsl(data.query))
viewset = resolve(data.path).func.cls
queryset = viewset.filter_class(data=params).qs
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question