我只想显示更新和删除链接到 django 博客中帖子的作者。但是{% if request.user == posts.author %}在模板上抛出错误Could not parse the remainder: '==posts.author' from 'request.user==posts.author'。我该如何解决这个问题?Views.pydef post_detail(request,slug): posts=Post.objects.get(slug=slug) posts.seen_by=posts.seen_by+1 posts.save() context={'posts':posts} return render(request,'blog/post_detail.html',context)post_detail.html{% extends 'blog/base.html'%}{% block content%} <a href="{%url 'post-cate' posts.category %}">{{posts.category}}</a> <p>{{posts.date_posted}}</p> <h1>{{posts.title}}</h1> {% if request.user==posts.author %} <p><a href="{% url 'post-update' posts.slug %}">Update</a> <a href="{% url 'post-delete' posts.slug %}">Delete</a> </p> {% endif%} <strong>{{posts.content}}</strong><p>- <a href="{% url 'post-by-user' posts.author %}">{{posts.author}}</a></p> Seen:{{posts.seen_by}} <hr>{% endblock content%}
添加回答
举报
0/150
提交
取消