Redirect Django with paramentros

0

I'm running a payment gateway in Django and I'm trying to split the procedure into two views, one makes the call and gets the answer and the second processes the response.

Right now my code is something like this:

def comprar(self):
    ...
    result = realizar_compra(pedido,perfil,tarjeta_data,request)
    print(result)
    return redirect('confirmacion-compra',args={'respuesta':result,'perfil':perfil,'producto':producto})

and there is my answer view:

@login_required
def confirmacion_pago(request):
    ...
    return render(request, 'intranet/confirmacion_comprar.html',{'mensaje':'Pago realizado correctamente.','perfil':perfil,'producto':producto})

I want to send the result variable to the second function so that it checks the data and maps the response page so that there is no way to go back to the previous screen or by default reload the page and make the payment again.

    
asked by F Delgado 02.04.2018 в 16:34
source

1 answer

1

Under my point of view you have two options

  • Send by redirect
  • by httpResponse and its context when you send by redirect the view must receive the arguments example:

    return anotherView (request, username, range)

receiving:

def anotherView(request,username,range):

METHOD TWO:

context={
{
'mensaje':'Pago realizado correctamente.',
'perfil':perfil,
'producto':producto
}
return render(request, 'intranet/confirmacion_comprar.html', context)

I hope you serve and luck !!

    
answered by 04.04.2018 / 19:58
source