D
D
Domohod2022-01-03 10:39:17
Django
Domohod, 2022-01-03 10:39:17

Why the error: AttributeError: 'str' object has no attribute '_meta'?

Making django comments using django-comments-xtd
During template creation, the error described in the question occurs.
Template (as stated in the documentation):

{% extends "layout/base.html" %}

{% load comments %}

{% block home %}

<body>

{% get_comment_count for object as comment_count %}
<div class="py-4 text-center">
  <a href="{% url 'blog:post-list' %}">Back to the post list</a>
  &nbsp;&sdot;&nbsp;
  {{ comment_count }} comment{{ comment_count|pluralize }}
  ha{{ comment_count|pluralize:"s,ve" }} been posted.
</div>

</body>

{% endblock %}


How can I fix this error?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2022-01-03
@Domohod

Judging by the error, you passed a string somewhere instead of a model object. More precisely, it is impossible to say without a full backtrace.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question