我正在仿
http://andrew-liu.gitbooks.io/django-blog/content/template.html 来搭建博客。
出现错误,一时查不出来。求大神指点。
article/
view.py 1 from datetime import datetime
2
3 from django.shortcuts import render
4 from django.http.response import HttpResponse
5
6 from article.models import Article
7
8
9 def home (request ):
10 post_list = Article.objects.all ()
11 return render (request. 'home.html', {'post_list': post_list,})
12
13
14 def detail (request, my_args ):
15 post = Article.objects.all ()[int (my_args )]
16 str = ("title=%s, category=%s, date_time=%s, content=%s"
17 % (post.title, post.category, post.date_time, post.content ))
18 return HttpResponse (str )
网页端报错如下:
invalid syntax (
views.py, line 11 )
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.8.4
Exception Type: SyntaxError
Exception Value:
invalid syntax (
views.py, line 11 )
Exception Location: /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/
__init__.py in import_module, line 37
Python Executable: /Users/tjx/EVN2.7/bin/python
Python Version: 2.7.10
就是说 11 行有语法错误啊。我看了 11 行, render 的那三个参数都 ok 。怎么就语法错误了?
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
https://www.v2ex.com/t/219170
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.