Python 评论形式不';使用django注释xtd时不加载
我对Django和Python都是新手,正在尝试创建我的博客。我的设置由运行在windows 10上的Django 2.0.7和Python 3.6.5组成。我只配置了一个名为“personal”的应用程序。在我的例子中,页面加载了“0条已发布的评论”,它不会呈现评论表单 下面是我的代码片段 settings.py配置 url.py(个人应用下的url.py) 视图(在个人应用程序下) 最后是page_detail.htmlPython 评论形式不';使用django注释xtd时不加载,python,html,django,django-comments,Python,Html,Django,Django Comments,我对Django和Python都是新手,正在尝试创建我的博客。我的设置由运行在windows 10上的Django 2.0.7和Python 3.6.5组成。我只配置了一个名为“personal”的应用程序。在我的例子中,页面加载了“0条已发布的评论”,它不会呈现评论表单 下面是我的代码片段 settings.py配置 url.py(个人应用下的url.py) 视图(在个人应用程序下) 最后是page_detail.html 我的页面 {%load static%} {%include'per
我的页面
{%load static%}
{%include'personal/head.html%}
{%loadcomments%}
{%load comments_xtd%}
我的博客详情
专题1:
- 细节1
{%get_comment_count作为注释_count%}
⋅
{{comment_count}}已发布评论。
{%if mycomm.allow_comments%}
你的评论
{%render_comment_form for mycomm%}
{%endif%}
{%if注释_计数%}
{%render\u xtdcomment\u mycomm%的树}
{%endif%}
删除注释表单标记周围的if标记,即
{% if mycomm.allow_comments %}
<div class="comment">
<h4 class="text-center">Your comment</h4>
<div class="well">
{% render_comment_form for mycomm %}
</div>
</div>
{% endif %}
{%if mycomm.allow_comments%}
你的评论
{%render_comment_form for mycomm%}
{%endif%}
现在应该是
<div class="comment">
<h4 class="text-center">Your comment</h4>
<div class="well">
{% render_comment_form for mycomm %}
</div>
</div>
你的评论
{%render_comment_form for mycomm%}
我也使用了下面的教程。我所有的html页面都是静态的,并且都托管在“personal/templates/personal”位置上。太棒了!现在表单开始显示,但它显示在页面顶部,不可编辑。我不知道为什么它不可编辑,但我认为您应该使用{%get_comment_form%}标记并对其进行迭代,看看它是否有效
def page1(request):
mycomm =Recipiecomments()
return render(request, 'personal/blackforestcake.html',locals())
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>My Page</title>
{% load static %}
</head>
<body>
<div class="fh5co-loader"></div>
<div id="page">
{% include 'personal/head.html' %}
{% load comments %}
{% load comments_xtd %}
<div id="fh5co-author">
<div class="container">
<div class="row top-line animate-box">
<div class="col-md-8 col-md-offset-2">
<h2>My Blog detail</h2>
</div>
</div>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<p class="animate-box"><img src="{% static "personal/img/pic" %}" class="img-responsive" alt="image"></p>
<div class="testimony animate-box">
<blockquote>
<h3>Topic 1:</h3>
<ul>
<li>Detail 1</li>
</ul>
</blockquote>
</div>
{% get_comment_count for mycomm as comment_count %}
⋅
{{ comment_count }} comments have been posted.
</div>
{% if mycomm.allow_comments %}
<div class="comment">
<h4 class="text-center">Your comment</h4>
<div class="well">
{% render_comment_form for mycomm %}
</div>
</div>
{% endif %}
{% if comment_count %}
<hr/>
<ul class="media-list">
{% render_xtdcomment_tree for mycomm %}
</ul>
{% endif %}
</div>
<div class="gototop js-top">
<a href="#" class="js-gotop"><i class="icon-arrow-up"></i></a>
</div>
</body>
</html>
{% if mycomm.allow_comments %}
<div class="comment">
<h4 class="text-center">Your comment</h4>
<div class="well">
{% render_comment_form for mycomm %}
</div>
</div>
{% endif %}
<div class="comment">
<h4 class="text-center">Your comment</h4>
<div class="well">
{% render_comment_form for mycomm %}
</div>
</div>