Answer the question
In order to leave comments, you need to log in
How to automatically set the value of the Inline field of the model in the admin panel?
You need to set the value of the ForeignKey field in the Inline admin model.
The value is the id of the main table.
I suspect that this should be done through the form, but I need a hint how exactly.
Answer the question
In order to leave comments, you need to log in
Doesn't Django do this automatically? This field is the link between the two models and no body movements should be required.
If you have, for example, the page for adding the Author entity in the admin panel, and on it there are inline with the Book entities, then when you add the author and several of his books, 1 record will be created in the database in the authors table, and the required number of records in the table of books associated with by this added author.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question