U
U
User992019-03-22 23:17:27
Django
User99, 2019-03-22 23:17:27

How to implement such request in django?

Started learning Django.
How to make such a query to the database, in PHP I did this:

$fames = pg_query ($connect, "SELECT DISTINCT(ugods),(ugodp) FROM halloffames");
while ($row = pg_fetch_assoc($fames))
{
$ugods = $row['ugods'];
$ugodp = $row['ugodp'];
$famesact = pg_query ($connect, "SELECT * FROM halloffames WHERE ugods=$ugods AND ugodp=$ugodp");
while ($rowfamesact = pg_fetch_assoc($famesact)){
echo $rowfameact['....'];
}
}

That is, there is a table halloffames,
Ugods Ugodp Fam Im otc
2016 2017 Markov Vasya
2016 2017 Antonov Anton Antonovich
2017 2018 Sergeeva Karina Vitalievna
2017 2018 Pavlov Pavel Pavlovich
2018 2019 Pavlova Anna Pavlovna
first I get DISTINCT academic years, then in a cycle I make a request with these values ​​and display their results
Now I don't know how to make such a query in Django and display the results in templates
in Django
def HallOfFame(request):
    ugodlist= Halloffames.objects.values('ugods','ugodp').distinct()
    for godlist in ugodlist:

I don't know anymore :)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question