Answer the question
In order to leave comments, you need to log in
Doesn't find Django self-written templatetag, why is it not clear?
Actually, it is in the genres_list.py file
This is how it is located:
movies
templatetags
__init__.py
genres_list.py
This is how it is called in the template
{% load genres_list %}
And this is how it is used:
{% for genre in genres %}
{{ genre.title }}
{% endfor %}
from django import template
from ..models import Genre
register = template.Library()
@register.inclusion_tag('movies/movie_list.html')
def genres():
return {'genres': Genre.objects.all()}
UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: QuerySet.
return self.paginator_class(
Answer the question
In order to leave comments, you need to log in
# Пункт 3. Возвращайте так в файле темплейттега
return Genre.objects.all()
# html files
{% get_genres as data_genres %}
# html files
{% for genre in data_genres %}
{{ genre.title }}
{% endfor %}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question