Answer the question
In order to leave comments, you need to log in
How to display data in django?
There are two models
, the 1st model is nested in the 2nd. It is
necessary that some data (variable data) from the 2nd model be output to the 1st model, so that the inheritance of the 2nd model to the 1st is shown
Answer the question
In order to leave comments, you need to log in
Suppose you have a model FirstModel, where one of the fields (second_model) is a Foreign Key on SecondModel
You get an instance of the first model
my_instance = FirstModel.objects.get(id=1)
my_instance.second_model.field
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question