I have this code
#VIEWS
def report_pdf(request, queryset):
if request.method == "GET":
trans = Transaction.objects.filter(id__in=queryset)
return something
#URLS
path("pdf/<uuid:queryset>", views.report_pdf, name="get_pdf")
Now from my frontend react iam sending a get request to this endpoint with a list of UUID values.
I cant find a way to access that list in my view coming from frontend.
Would appreciate any suggestions!
CodePudding user response:
You are sending list of uuid's from frontend but in your urls expects one uuid so that you need to change it like this:
urls.py:
path("pdf/", views.report_pdf, name="get_pdf")
views.py:
def report_pdf(request):
if request.method == "GET":
uuid_list = request.GET.getlist("queryset[]")
trans = Transaction.objects.filter(id__in=uuid_list)
return something
CodePudding user response:
I would suggest you pass the uuids as query params to the url as
../pdf?queryset=<uuids here>
then get the list in your view as
queryset = request.GET.get('queryset')
and then use queryset further in view.
