S
S
Sama Samsonov2016-12-22 12:19:09
Django
Sama Samsonov, 2016-12-22 12:19:09

How to bind django sql queries to a view and send the result to the template?

There is a method

def main_rospis(request):
    pred = Rospisanie.objects.raw('Select full_name as den, vremy as nachalo, nazvanie as gruppa, name as predmet, surname as prepod from DniNedeli_dninedeli INNER JOIN rospisanie_rospisanie ON DniNedeli_dninedeli.id = rospisanie_rospisanie.kod_dny_r_id INNER JOIN urok_urok ON urok_urok.id = rospisanie_rospisanie.urok_r_id INNER JOIN gruppa_gruppa ON gruppa_gruppa.id = rospisanie_rospisanie.gruppa_r_id INNER JOIN predmet_predmet ON predmet_predmet.id = rospisanie_rospisanie.predmet_r_id INNER JOIN prepod_prepodavatel ON prepod_prepodavatel.id = rospisanie_rospisanie.prepod_r_id')

    return render(request, 'papka/list.html', {'preds':pred})

in the template (list.html) is not displayed. How can I fix it?
in general I need to execute this query and get the result.
the request itself is correct.

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