I want to pass parameters along with url condition based

9 views
Skip to first unread message

Softtar

unread,
Oct 18, 2020, 7:27:48 AM10/18/20
to Django REST framework
I want to retrieve data behalf of mobile number or cnic number how I can give conditionally parameters

Here is the url
path('api/filterapplication/<cnic> || <mobile>', ApplicationLIST1.as_view()),

Here is the my view.py
class ApplicationLIST1(generics.ListAPIView):
def get(self, request, cnic, mobile):
snippets = Application.objects.filter(cnic=cnic) | Application.objects.filter(mobile=mobile)
serializer = ApplicationSerializer(snippets, many=True)
return Response(serializer.data)
It's now working 
Reply all
Reply to author
Forward
0 new messages