A
A
Almaz Akimov2021-11-30 16:59:40
Python
Almaz Akimov, 2021-11-30 16:59:40

Django QuerySet how to filter?

Created a model with movie sessions.
61a6294e7e357023259674.png
In views.py created a handler

def index(request):
    posts = Show.objects.all()
    context = {
        'posts': posts,
        'menu': menu,
        'title': 'Главная страница',
        'cat_selected': 0,
    }
    return render(request, 'movie/index.html', context=context)

Using a template engine I create a page:
{% for p in posts  %}
              Год: {{p.movie.year}}
              Жанр: {{p.movie.genre}}
             Время показа 1:  {{p.show.time}}
             Время показа 2:  {{p.show.time}}
        {% endfor %}

How can I do if there are several sessions with one movie, then the movie was not duplicated, but only recorded in the template (Show time 2: )

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2021-11-30
@GolosB

https://docs.djangoproject.com/en/3.2/ref/template...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question