Answer the question
In order to leave comments, you need to log in
Why does the form from views.py not save the value entered by the user?
All values entered from the forms of the pat.html page are stored in the database.
But the point is that when entering data from these 2 forms, form.Ticket and form.param would be passed to the next script that climbs into the database, connects to it using psycopg2 and changed the data already in the connected database (the script for changing the database to pg itself is working, these parameters are not transferred to the next script, it only goes to the internal database on sqlite
def pat(request):
error = ''
if request.method == 'POST':
form = PatForms(request.POST)
if form.is_valid():
Ticket = request.POST['Ticket']
param = request.POST['param']
form.save()
return redirect('pat')
else:
error = 'Номер заявки и заявления не должны быть строкой (тип int)'
form = PatForms()
context = {
'form': form,
'error': error,
}
return render(request, 'main/pat.html', context,)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question