Рендеринг значений в Html с помощью Python Django
** HTML-ФАЙЛ **
{% extends 'shop/layouts/main.html' %} {% block content %}
<div class="container">
<div class="row">
<div class="col-12">
<h1>Collections</h1>
{% for item in items %}
{{ item.name }}
{% endfor %}
</div>
</div>
</div>
{% endblock content %}
** ФАЙЛ VIEWS.PY **
from django.shortcuts import render
from . models import *
def collections(request):
items = Product.objects.all()
return render(request, "shop/collections.html", {"Item": items})
Мне нужна помощь, я не могу загрузить мои {items} на html, он просто ничего не показывает в выводе
Ваш контекст говорит Item
, но ваши шаблоны пытаются получить доступ к items
- убедитесь, что имена совпадают, и все должно работать.