Python django评论应用程序无法显示表单

Python django评论应用程序无法显示表单,python,django,Python,Django,在阅读了django comments框架之后,我就要实现它了,所以我将它安装在我的settings.py文件中,并开始使用模板标记(我使用的是django 1.6,我知道它已被弃用,但它应该适用于我将要使用它的用途) 当试图使用 {% get_comment_form for <object> as <var %} 这是模板代码的一部分,其中im使用模板标记: {% get_comment_form for experience_details as form %} <

在阅读了django comments框架之后,我就要实现它了,所以我将它安装在我的settings.py文件中,并开始使用模板标记(我使用的是django 1.6,我知道它已被弃用,但它应该适用于我将要使用它的用途)

当试图使用

{% get_comment_form for <object> as <var %}
这是模板代码的一部分,其中im使用模板标记:

{% get_comment_form for experience_details as form %}
<table>
  <form action="{% comment_form_target %}" method="POST">
    {% csrf_token %}
    {{ form }}
    <tr>
      <td colspan="2">
        <input type="submit" name="submit" value="Post">
        <input type="submit" name="preview" value="Preview">
      </td>
    </tr>
  </form>
</table>
{%get_comment_form for experience_details_form%}
{%csrf_令牌%}
{{form}}

您需要模板标签的RequestContext。 出现此问题是因为缺少某些变量,模板无法正确呈现

您可以通过以下方式导入RequestContext:

from django.shortcuts import render_to_response
from django.templates.context import RequestContext

def display_story(request, specific_story):

    this_view_context = {
                'story_details': story_details,
                'story_votes': story_votes
                }
    request_context = RequestContext(request, this_view_context)
    return render_to_response( "base/story/display_story.html", request_context)

您可以使用render\u to\u response或render,这是您的选择

谢谢您的回答,但这并不正确。如果您只使用render而不是render_to_响应,您将获得一个与我一样的呈现上下文,并且您不需要显式添加RequestContext,这样就不会出现问题。经过更多的故障排除后,我将应用程序移出当前应用程序范围,并将配置直接放在global urls.py中,然后它工作了,但我还没有找到问题的原因。
{% get_comment_form for experience_details as form %}
<table>
  <form action="{% comment_form_target %}" method="POST">
    {% csrf_token %}
    {{ form }}
    <tr>
      <td colspan="2">
        <input type="submit" name="submit" value="Post">
        <input type="submit" name="preview" value="Preview">
      </td>
    </tr>
  </form>
</table>
from django.shortcuts import render_to_response
from django.templates.context import RequestContext

def display_story(request, specific_story):

    this_view_context = {
                'story_details': story_details,
                'story_votes': story_votes
                }
    request_context = RequestContext(request, this_view_context)
    return render_to_response( "base/story/display_story.html", request_context)