Using django_comments but getting 'QuerySet' object has no attribute '_meta'

南笙酒味 提交于 2019-12-13 06:08:34

问题


My django project named comments is here. It has an app comms which is there to display comments using django_comments.

I have

  1. installed django_comments
  2. put it in INSTALLED_APPS field in settings.py
  3. have defined SITE_ID = 1
  4. enabled the sites framework
  5. put url(r'^comments/', include('django_comments.urls')) in urls.py

But this template file is giving me this error:

AttributeError at /

'QuerySet' object has no attribute '_meta'

What am I missing?


回答1:


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>

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.



来源:https://stackoverflow.com/questions/30026483/using-django-comments-but-getting-queryset-object-has-no-attribute-meta

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!