K
K
Kirill Pisarev2016-12-16 14:20:23
Django
Kirill Pisarev, 2016-12-16 14:20:23

How to render two models into one table?

There are two fairly large models, one is a list of transactions and the other is a list of exchange orders. Historically, they were displayed on different pages, but it became necessary to display them in one table, sorted by time.
The problem is that the models are completely different, have different fields, but both have a foreign key to the user model.
Accordingly, you need to somehow combine their QuerySets and sort them.
The only solution that I see is to display them using, for example, React, having received JSON from the server combining two models, but unfortunately this is long.
Perhaps there are other faster options?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2016-12-16
@vintello

try using database view
like this recipe

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question