Django 注释未显示在模板中
我无法在模板中显示我的评论。当我在 shell 中测试对象注释时 - 返回注释列表,它们看起来很好。但是在我的模板中它们没有出现。当我包含 {% load comments %} 时,加载页面确实需要更长的时间,但是当包含 {% render_comment_list for my_video %} 时,不会显示任何内容,其中“my_video”是我的 obj 实例。
关于如何调试这个有什么建议吗?
I'm having trouble getting my comments to display in my template. When I test an objects comment in the shell - a list of comments are returned and they seem fine. However in my template they don't appear. It does take longer to load the page when I include {% load comments %} however nothing is shown when include {% render_comment_list for my_video %} where 'my_video' is my obj instance.
Any suggestions on how to debug this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试以下步骤
确保该视频至少有一条评论。您可以在views.py的开头添加以下内容:
from django.contrib.comments.model import Comment
并在渲染模板之前:print Comment.objects.filter(content_type = MyVideoType , object_pk = my_video.pk)
如果您有评论,请确保评论是公开的。
将以下内容添加到您的
urls.py
django.contrib。注释
添加到settings.py中的INSTALLED_APPS
中。否则,如果您可以显示视图和模板,将会很有帮助。
Try the following steps
Make sure, that there is at least one comment for the video. You can add the following at the beginning of your views.py:
from django.contrib.comments.model import Comment
and before rendering the template:print Comment.objects.filter(content_type = MyVideoType, object_pk = my_video.pk)
If you have comments, make sure that the comments are public.
Add the following to your
urls.py
django.contrib.comments
added to yourINSTALLED_APPS
in the settings.py.Otherwise it would be helpful if you can show the view and the template.