models.py
from django.db import models
class Posts(models.Model):
title = models.CharField(max_length=50,name='Название поста')
description = models.TextField(name='Содержание')
data = models.DateField(name='Дата')
time = models.TimeField(name='Время')
class Meta:
verbose_name = 'Запись'
verbose_name_plural = 'Записи'
def __str__(self):
return f'{self.title}'
views.py
from django.shortcuts import render
from django.views.generic.base import View
from django.urls import reverse_lazy
from django.contrib.auth.forms import UserCreationForm
from django.views.generic.edit import CreateView
from .models import Posts
def homepage(request):
posts = Posts.objects.all()
return render(request,'main/home.html',{'posts':posts})
blog.html
{% load static %}
<!DOCTYPE>
<html >
<head>
<title>Мой блог</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="{% static 'css/style.css' %} " type="text/css" media="all" />
<link rel="shortcut icon" href="css/images/favicon.ico" />
</head>
<body>
<div class="shell">
<div class="border">
<div id="navigation">
<ul>
<li><a href="#" class="active">Главная</a></li>
<li><a href="#">Админ панель</a></li>
</ul>
</div>
<div id="main">
<div id="content" class="left">
<div class="projects">
{% if post.title > 0 %}
<h3>Записи</h3>
{% for post in posts %}
<div class="item">
<div class="image left">
<a href="#"><img src="css/images/project01.jpg" alt="" /></a>
</div>
<div class="text left">
<h4></h4>
<p>{{post}}</p>
</div>
<div class="cl"> </div>
</div>
{% endfor %}
</div>
</div>
<div class="cl"></div>
</div>
{% endif %}
</div>
<div id="footer">
<p class="copy right">Copyright © 2022 </p>
</div>
</div>
</body>
</html>
Сама ошибка: