Get url param in django

I have this view:

def newAnswer(request, id):
    post = Post.objects.get(id=id)
    form = AnswerForm(request.POST)
    if request.method == 'POST':
        if form.is_valid():
            obj =
   = request.user
   = post
            return redirect('main:post',
            return render(request, 'main/newAnswer.html', { 'form': form, 'formErrors': form.errors, 'userAvatar': getAvatar(request.user)})
        return render(request, 'main/newAnswer.html', {'form': form, 'post': post, 'userAvatar': getAvatar(request.user)})

When i try to post without loging in, it redirects me to "/accounts/login?next=/post/answer/new/81".

My question is how can i get the "next" param in my login view


Everything arguments (params) you can see in url mean that request is done with GET method. Use request.GET.get('next', None).

Back to Top