[Django]-Django redirect() with additional parameters

10👍

If you don’t want to pass the email via the URL in the redirect, it may be easiest to store it in the session.

def first(request):
    request.session['email'] = 'some_email'
    return redirect('confirm')

def confirm(request):
    return render(request, 'template.html', {'email': request.session['email']})

2👍

Configure the url pattern to capture the email. e.g.

urlpatterns += [
    url(r'^booking_confirmation/(?P<email>\w+)$', views.confirm, name='confirm'),
]

You can use more robust pattern-match for the captured email instead of capturing only word characters.

Leave a comment