我遵循了制作博客引擎的教程并成功集成了它。只是这个模板不起作用,我不知道为什么。可能是什么问题?
这是模板:
{% extends "base.html" %}
{% block title %}{% post.title %}{% endblock %}
{% block content %}
<h3>{{ post.title }}</h3>
<p>Posted on {{ post.published|date:"F j, Y" }}<p>
{{ post.description|safe }}
<br>
{{ post.body|safe }}
<br>
{% if previous_post %}
<a href="{{ previous_post.get_absolute_url }}" title="{{ previous_post.title }}">
« Previous Post: {{ previous_post.title }}
</a>{% endif %}
{% if previous_post and next_post %} | {% endif %}
{% if next_post %}
<a href="{{ next_post.get_absolute_url }}" title="{{ next_post.get_absolute_url }}">
Next Post: {{ next_post.title }} »
</a>
{% endif %}
{% endblock content %}
这是views.py:
def detail(request, sl):
try:
post = Post.objects.filter(slug=sl)[0]
try:
previous_post = post.get_previous_by_published()
except:
previous_post = ""
try:
next_post = post.get_next_by_published()
except:
next_post = ""
except:
next_post = ""
previous_post = ""
post = ""
return render_to_response('blog/detail.html', {'post':post,
'next_post':next_post,
'previous_post':previous_post,
},)