使用django_comments但是获取'QuerySet'对象没有属性'_meta' [英] Using django_comments but getting 'QuerySet' object has no attribute '_meta'
本文介绍了使用django_comments但是获取'QuerySet'对象没有属性'_meta'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的名为评论
的django专案是这里 。它有一个应用程序 comms
,使用 django_comments
显示评论。
My django project named comments
is here. It has an app comms
which is there to display comments using django_comments
.
我有
- 已安装
django_comments
- 已将
SITE_ID = 1
的INSTALLED_APPS字段中的$ b
- 启用网站框架
- 放置
url(r'^ comments / 'django_comments.urls')) in
urls.py
- installed
django_comments
- put it in INSTALLED_APPS field in
settings.py
- have defined
SITE_ID = 1
- enabled the sites framework
- put
url(r'^comments/', include('django_comments.urls'))
inurls.py
但是此模板文件会向我显示此错误:
But this template file is giving me this error:
AttributeError在/
AttributeError at /
'QuerySet'对象没有属性'_meta
'QuerySet' object has no attribute '_meta'
我失踪了什么?
推荐答案
将您的home.html更改为以下内容:
Change your home.html to something like:
{% load comments %}
<html>
{% for entry in categ %}
{% get_comment_count for entry as comment_count %}
{% render_comment_list for entry %}
{% empty %}
<p> categ not present </p>
{% endfor %}
</html>
根据我的理解,模板标签以一个对象作为参数,但是你提供了Queryset objects.all())。
As I understand the template tags take an object as parameter, but you have provided the Queryset(Category.objects.all()).
未测试代码,但类似的东西应该可以工作。
Not tested the code, but something similar should work.
这篇关于使用django_comments但是获取'QuerySet'对象没有属性'_meta'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文