Ошибка при перенаправлении одной страницы на другую в django

В принципе, у страницы from и to есть параметры, поэтому как я могу перенаправить на страницу с параметрами?

if request.method == "POST":
 if request.POST.get('firstname') and request.POST.get('lastname') and request.POST.get('addln1') 
 and request.POST.get('addln2') and request.POST.get('country') and request.POST.get('city') and 
 request.POST.get('zip') and request.POST.get('smsno') and request.POST.get('whtspno') and 
 request.POST.get('email') and request.POST.get('deptnm') and request.POST.get('brdctlst'):
                saverecord = AddContact()
                saverecord.f_name = request.POST.get('firstname')
                saverecord.l_name = request.POST.get('lastname')

Для перенаправления на другую страницу в Django с параметрами используйте это

return HttpResponseRedirect(reverse(viewname='the view to which it should redirect', args=(parameters to be passed)))

Используйте redirect, это проще, чем напрямую вызывать reverse и HttpResponseRedirect. (Doc)

from django.shortcuts import redirect
...
    return redirect( 'myapp:url_name', urlparam=value, ...)

, что то же самое, что и

    return HttpResponseRedirect( 
         reverse( 'myapp:url_name',
         kwargs={ 'urlparam': value, ... } 
    )
Вернуться на верх