[Answered ]-Django queryset filter by post variable

1👍

Just use

couponCode = request.POST['code']

instead of

couponCode = str(request.POST.get("code"))

1👍

Remove the str() part. Leave it only as:

couponCode = request.POST.get("code"),
then you could do:

Coupon.objects.filter(code=couponCode)

Hope this helps.

👤Rigo

Leave a comment