A
A
Anton2018-10-04 10:20:36
Django
Anton, 2018-10-04 10:20:36

How to pass data from a website form to a Python function?

Can you please tell me how to pass data from a site form to a Python function?
I can’t figure out the process algorithm itself, what goes where? In the information that I found on the Internet, they create a form in models, then it is generated on the site and already becomes, as it were, tied to the models. But what if the form has already been created on the site manually, for example:

<form method="GET" action="/admi">
      <label for="your_name">Your name: </label>
      <input id="your_name" type="text" name="object" value=""> <!-- В "value=", можно внести значение по умолчанию -->
      <input type="submit" value="OK">
    </form>

How to force to transfer its data to function of a python?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Tikhonov, 2018-10-04
@8toni8

When you click the "OK" button on a form in a browser window, an HTTP request is made on the action specified in the form with the specified method. See HTTP .
The form data, depending on which method and content type is used, is sent in different parts of this request in different formats. See HTTP/POST
This data goes to the Django backend and is routed there depending on the list of routes in the view. See Django views .
To make it easier to work with forms, Django has done a bunch of things to make it easier to parse, validate, and process form data. See working with forms in Django .
In general, you can not re-read to read.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question