[Django]-HttpResponseRedirect Reverse not working Django


Given the template your urls.py specify an app_name. You need to use that as prefix in the name of the view.

Furthermore you can make use of redirect(…) [Django-doc] which calls reverse and wraps the result in a HttpResponseRedirect (so it removes some boilerplate):

from django.shortcuts import redirect

def LikeView(request, pk):
    post = get_object_or_404(Post, id=request.POST.get('post_id'))
    return redirect('score:post-detail', pk=pk)

Leave a comment