Данные не извлекаются из базы данных в python django

Я сохранил несколько постов в базе данных и получаю посты для отображения в list.html. Но данные не отображаются.

main Urls.py

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('blog/', include('blog.urls',namespace='blog')),
]

app url.py

from django.urls import path
from . import views

app_name = 'blog'

urlpatterns = [
    path('',views.post_list,name='post_list'),
    
path('<int:year>/<int:month>/<int:day>/<slug:post>/',views.post_detail,name='post_detail'),
]

Views.py

from django.core import paginator
from .models import Post
from django.shortcuts import render, get_list_or_404
def post_list(req):
    posts = Post.published.all()
    return render(req,'blog/post/list.html',{'posts':posts})

def post_detail(req, year,month,day,post):
    post = get_list_or_404(Post,slug=post,status='published',publish__year=year,publish__month=month,publish__day=day)
    return render(req,'blog/post/detail.html',
    {'post':post})

list.html

<h1>MyBlog</h1>
{% for post in posts %}
<h2>
    <a href="{{post.get_absolute_url}}">a{{post.title}}</a></h2>
<p class="date">
    Published{{post.Publish}} by {{post.author}}
</p>
{{post.body|truncatewords:30|linebreaks}}
{% endfor %}

Обычно это Post.objects.all().

Вернуться на верх