0
How to redirect passing an object as parameter in Django already tried
redirect()
and HttpResponseRedirect
but I can’t send an object to page in Sponse, every time I hit F5 it wants to resend the request. How
solve this problem ?
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import redirect, render
from webapp.metodos.gauss import Gauss
from django.urls import reverse
import numpy as np
import csv
import io
def index(request):
if request.method == 'POST':
matriz = readCSV(request)
return render(request, 'index.html', {'matriz': matriz})
return render(request, 'index.html')
def gauss(request):
if request.method == 'POST':
g = Gauss()
matriz = readCSV(request)
resultado = g.executar(matriz)
return render(request, 'gauss.html', {'resultado': resultado})
return render(request, 'gauss.html')
def gaussjordan(request):
return render(request, 'gaussjordan.html')
def fatoracaolu(request):
return render(request, 'fatoracaolu.html')
def readCSV(request):
data = request.FILES['file'].read().decode('UTF-8')
io_string = io.StringIO(data)
matriz = np.loadtxt(io_string, delimiter=',', dtype=int)
return matriz
<form class="form-group" action="{% url 'index' %}" method="POST"
enctype="multipart/form-data">
{{ form.file }}
{% csrf_token %}
<input type="submit" value="Executar">
<input type="file" name="file" id="arquivo" required />
<form>
Are you looking to redirect to a page after the Submit of a form? Could you post the full view code?
– Victor Fernandes
correct I want to redirect passing an object that will be loaded on the page changed code put form
– Eduardo Sampaio
Put the view code, where you process the form, all the code if possible, because I think using a CCBV will be better, but to tell you how to do it, I’ll need to see the view.
– Victor Fernandes
I put all view and form code in html
– Eduardo Sampaio