我正在尝试将书籍对象列表发送到我的模板以显示它们的名称和图像。这是我的书籍类
class Book(models.Model):
title=models.CharField(max_length=100)
zonar=models.CharField(max_length=20)
book_id=models.IntegerField(default=10)
image=models.ImageField()
file=models.FileField(upload_to="cars",default="")
这是我的 Django 视图
def books_display(request,zonar):
###########
###########
zonar_books=Book.objects.filter(zonar=zonar)
books={"zonar":zonar,"zonar_books":zonar_books}
return render(request,"books/books_listed.html",books)
最后这是我的模板
<<!DOCTYPE html>
<html dir="ltr">
<head>
<meta charset="utf-8">
<title>
{% if zonar %}
{{ zonar }}
{%endif%}
books </title>
</head>
<body>
{% if zonar_books %}
{% for book in zonar_books %}
<h1>{{ book.tile}}</h1>
{% endfor %}
{% endif %}
</body>
</html>
我收到以下错误
Error during template rendering
In template C:\Users\Sriram\Desktop\books_site\books\templates\books\books_listed.html, error at line 12
no such column: books_book.zonar
Qyouu
德玛西亚99
相关分类