使用<a href='...'>name<a>实现点击"name"与转向'...'网址的超链接操作
from django.shortcut import redirect导入redirect方法: return redirect('/')实现返回首页
def showpost(request, slug):
template = get_template('post.html')
try:
post = Post.objects.get(slug=slug)
if post != None:
html = template.render(locals())
return HttpResponse(html)
except:
return redirect('/')