F
F
Flarid2019-08-08 17:00:10
Django
Flarid, 2019-08-08 17:00:10

Django Foreign Key save in Models?

Hello everyone, do not judge strictly, I'm just learning) I have a form in HTML. I send the data from this form using the Post method to the Django server. The server receives this data. Also, I have 2 tables.
The Persons table and the Gender table (in which 2 values ​​are recorded through the admin panel, Male and Female 5d4c287fd73c4041898871.jpeg). The idea is that the user has entered data, one of them is gender, for example Male. I clicked send, and the data was written to the database. The Persons table has a field called Gender that references the Gender table via a Foreign Key. Thanks to this, in the admin panel, I can choose from two values ​​(gender Male or Female) 5d4c289f37f0f163824582.jpeg. Here's the question, when I enter data in an HTML form and hit submit, I get an error because I do not understand in what form I should send the value Male or female

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