[Answered ]-Page not found (404) No x matches the given query

1๐Ÿ‘

โœ…

A couple of things that could be giving you problems:

In your redirect for ProductLike you use args

return HttpResponseRedirect(reverse('product-detail', args=[str(pk)]))

But when you get back to the view, you are looking for kwargs

likes_connected = get_object_or_404(Product, id=self.kwargs['pk'])

Try using kwargs in your redirect

return HttpResponseRedirect(reverse('product-detail', kwargs={'pk': pk}))

Also, in your ProductLike view you are referring to request.POST.get('product_id'))

However, you are not sending any fields by the name product_id. It looks like the like form sends blogpost_id, so the lookup in the view will always 404.

๐Ÿ‘คSamSparx

Leave a comment