Let's assume that I have GET request with URL domain/search/?value=123
and data in JSON:
[
{
"id": 1,
"value": 123,
"value2": 123123
},
{
"id": 2,
"value": 1,
"value2": 214
}
]
I would like to get data where value = 123
. In this case:
[
{
"id": 1,
"value": 123,
"value2": 123123
}
]
I have found information how to capture parameters from URL in this post. I wonder what I should do now to find best solution in Django. Thanks in advance.
How can I use it in views.py:
if request.method == 'GET':
myObject = myObjectClass.objects.all()
serializer = myObjectSerializer(myObject, many=True)
return Response(serializer.data)
when data from JSON is not only an integer.