TL;DR
If I understand correctly, just check in the view if your request uses the POST method, if yes, do the necessary processing and return the resulated. In the example below I create a template that asks for a date and a value, after the user’s submission, the view takes the value, multiplies by 2 and returns. The view, from the user’s first submission, shows what was typed in the previous submission and displays the value "corrected" (multiplied by 2):
In views.py:
from django.shortcuts import render
def home(request):
data = None
valor = None
new_valor = None
if request.method=='POST':
data = request.POST['data']
valor = request.POST['valor']
new_valor = int(valor)*2
# Faça aqui o que vc for precisos com os dados recebidos
return render(request, 'main/index.html', {'data': data, 'valor': valor, 'new_valor': new_valor})
In the template (in this case, index.html):
<form method="POST">
{% csrf_token %}
<label for="data">Data:</label>
<input id="data" type="date" name="data" value="" /><br>
<label for="valor">Valor:</label>
<input id="valor" type="number" name="valor" value="" /><br>
<input type="submit">
{% if data != None %}
<br><br>
<p>
Sua última digitação:<br>
Data Inicial: {{data}}<br>
Valor: {{valor}}<br>
Valor Corrigido: {{new_valor}}
</p>
{% endif %}
</form>
Presentation of the template after the first submission (Ubmit):
See working on repl.it.
It worked perfectly. Thank you very much.
– Jorge Gonzaga