这是我的代码,我在索引页面上收到错误** {%post for posts%}}模板渲染模板/home/elite/Downloads/django/FirstBlog/blog/templates/index.html期间出错,错误在第13行
的index.html
<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”utf-8”>
<title>Awesome HTML5 Webpage</title>
<meta name=”description” content=”An awesome HTML5 page YOU built from scratch!”>
<meta name=”author” content=”Udemy”>
<link rel=”stylesheet” href=”style.css”>
</head>
<body>
<div class='cointainer'>
<h1>First Blog</h1>
{% for post in posts %} <<<<- This where error I get--
<h2>{{ post.tittle }}</h2>
<h3>Posted{{ post.timestamp }} by {{ post.author }}</h3>
<p>{{post.bodytext }} </p>
{% endfor %}
</div>
</body>
</html>
观看页面
from django.shortcuts import render
from blog.models import posts
def home(request):
entries = posts.objects.all()[:10]
return render(request, 'index.html',{'posts' : entries})
这是网页
from django.conf.urls import patterns, include, url
from django.contrib import admin
urlpatterns = patterns('',
# Examples:l()
url(r'^admin/', include(admin.site.urls)),
url(r'^$', 'blog.views.home', name='home'),
)