S
S
Size240x3202021-08-01 10:08:43
Django
Size240x320, 2021-08-01 10:08:43

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,)


How it is possible to pull Ticket and param in the next script?
When I try to import these variables, I am only prompted by pat(request=)
And I need to substitute exactly these values ​​that were received from the form

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question