Get url param in django

I have this view:

@login_required
def newAnswer(request, id):
    post = Post.objects.get(id=id)
    form = AnswerForm(request.POST)
    if request.method == 'POST':
        if form.is_valid():
            obj = form.save(commit=False)
            obj.author = request.user
            obj.post = post
            obj.save()
            form.save_m2m()
            return redirect('main:post', id=post.id)
        else:
            return render(request, 'main/newAnswer.html', { 'form': form, 'formErrors': form.errors, 'userAvatar': getAvatar(request.user)})
    else:
        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

thanks!

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