N
N
nekaino2020-02-20 13:20:00
Debugging
nekaino, 2020-02-20 13:20:00

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
5e4e5d47047c5664022036.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DevMan, 2019-06-22
@freeman0204

D - debug.

S
sotanodroid, 2020-02-20
@sotanodroid

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)

through the point of specifying the second model, you get the keys from the second model
my_instance.second_model.field

But it would be better to see your models and how you are trying to get data.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question