Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django在评论后重定向_Python_Django_Redirect - Fatal编程技术网

Python Django在评论后重定向

Python Django在评论后重定向,python,django,redirect,Python,Django,Redirect,我是Django的新手,我试图理解为什么我的代码没有重定向到: http://127.0.0.1:8000/object/2/ 将我重定向到: http://127.0.0.1:8000/object/2/?c=14 添加此参数的代码在哪里 模板: {% if user.is_authenticated %} {% get_comment_form for object as comment_form %} <form action="{% comment_form_

我是Django的新手,我试图理解为什么我的代码没有重定向到:

http://127.0.0.1:8000/object/2/
将我重定向到:

http://127.0.0.1:8000/object/2/?c=14
添加此参数的代码在哪里

模板:

{% if user.is_authenticated %}
    {% get_comment_form for object as comment_form %}

    <form action="{% comment_form_target %}" method="POST">
        {% csrf_token %}
        {{ comment_form.comment }}
        {{ comment_form.content_type }}
        {{ comment_form.object_pk }}
        {{ comment_form.timestamp }}
        {{ comment_form.security_hash }}
        <input type="hidden" name="next" value="{{ object.get_absolute_url }}" />
        <input type="submit" value="post comment" />
    </form>
{% else %}
    <p>Please <a href="{% url 'auth_login' %}">log in</a> to leave a comment.</p>
{% endif %}
URL.py:

url(r"^comments/", include("django.contrib.comments.urls")),
url(r'^object/', include('realization.urls')),
实现/url.py:

urlpatterns = patterns('',
url(r'^(?P<pk>\d+)/$', realiz_photo_view.as_view()),
)

在这里查看我的解决方案:Django:


它基本上使用了一个由评论帖子url触发的视图,该url重定向回原始的推荐人页面。

您可以在url中共享评论表单目标url吗。py@Corey_C谢谢你的回答,但是你的链接断了。@Harkonnen对不起,我修复了链接。
urlpatterns = patterns('',
url(r'^(?P<pk>\d+)/$', realiz_photo_view.as_view()),
)