R
R
rm root2020-06-03 23:54:18
Django
rm root, 2020-06-03 23:54:18

Django 3, How to take data from one table and add a record to another table?

For example, I have a table "Halls" in this table there are fields:
room_number,
how many_rows,
number_of_seats_in_row,
capacity * - this field is necessary, we do not pay attention to it
5ed80bd98bde8784898740.png

When adding a record, I want to take data from the fields ( how many_rows, number -in_places_in_row ) and with this data create records in the "Places" table, for example, if we have 5 rows and 20
places in a row, then we get 100 records in the "Places" table,

but how to do this automatically when adding a record to the "Halls" table, then it automatically takes this data and fills it in a cycle in the table "Places" the

table "Halls" is filled only in the admin panel, not in the view

How to implement this ??? somehow in admin.py ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Tikhonov, 2020-06-04
@rm_root

Write a signal handler that creates seats when the hall is created.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question