我正在使用django.contrib.comments在博客上启用评论。
我在评论表单中添加了一个隐藏的‘下一步’字段,其中包含url,我希望用户在提交评论后返回该url,以便绕过posted.html模板,该模板工作正常。
<input name="next" type="hidden" value="{% url single_post slug=post.slug %}" />但是,在实现评论主持人之后,如下所示:
from django.contrib.comments.moderation import CommentModerator, moderator
class PostModerator(CommentModerator):
email_notification = True
moderator.register(Post, PostModerator),有一个错误,报告文件comments/comment_notification_email.txt丢失,所以我创建了这个文件,如下所示:
Comment: http://127.0.0.1{{ comment.get_absolute_url }}
From: {{ comment.person_name }}
-----
{{ comment.comment }}
-----
Admin: http://127.0.0.1/admin/comments/comment/{{comment.id}}/但是现在,Django抱怨请求URL http://127.0.0.1:8000/comments/post/不存在?如何才能最好地解决这个问题?
发布于 2010-11-17 00:33:55
在单独的视图中执行重定向解决了我的问题:
urls.py
(r'^comments/post/', 'app.views.comment'),views.py
def comment(request):
# Redirecting after comment submission
return HttpResponseRedirect(request.POST['next'])https://stackoverflow.com/questions/4125243
复制相似问题