Комментарии Django - объект 'str' не имеет атрибута '_meta'
Я пытаюсь реализовать систему комментариев и ответов в моем приложении для статей, но получаю следующую ошибку:
AttributeError: 'str' object has no attribute '_meta'
Не могли бы вы сообщить мне, что я делаю неправильно и как это исправить? Я проверил некоторые ответы, но они не относятся к этой конкретной библиотеке.
article_page.html
{% extends 'base.html' %}
{% load i18n %}
{% load comments comments_xtd static %}
{% block articleactive %}active{% endblock articleactive %}
{% block body %}
<div class="container">
<h1 class="py-3">{{ article.title }}</h1>
<p>{{ article.content | safe }}</p>
<br>
<p class=" text-muted">{{ article.author }} | {{ article.date_published }}</p>
<div class="container-fluid mt-4 comment-form">
{% render_comment_form for page %}
</div>
{% get_comment_count for page as comment_count %}
{% if comment_count %}
<hr>
<div class="container-fluid mt-4 media-list">
{% render_xtdcomment_tree for page allow_feedback show_feedback %}
</div>
{% endif %}
</div>
{% endblock body %}
setting.py
INSTALLED_APPS = [
'django_comments_xtd',
'django_comments',
'product',
'article',
'jazzmin',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'ckeditor',
'crispy_forms',
'taggit',
'axes',
'django_otp',
'django_otp.plugins.otp_totp',
'django.contrib.sites'
]
COMMENTS_APP = "django_comments_xtd"
COMMENTS_XTD_CONFIRM_EMAIL = False # Set to False to disable confirmation
COMMENTS_XTD_SALT = b"es-war-einmal-una-bella-princesa-in-a-beautiful-castle"
COMMENTS_XTD_FROM_EMAIL = 'noreply@example.com'
COMMENTS_XTD_CONTACT_EMAIL = 'helpdesk@example.com'
COMMENTS_XTD_MAX_THREAD_LEVEL = 1 # Default value
COMMENTS_XTD_LIST_ORDER = ('-thread_id', 'order') # default is ('thread_id', 'order')
COMMENTS_XTD_APP_MODEL_OPTIONS = {
'default': {
'allow_flagging': False,
'allow_feedback': True,
'show_feedback': True,
'who_can_post': 'users' # Valid values: 'all', users'
}
}
models.py
class Article(models.Model):
id = models.AutoField(primary_key=True)
title = models.CharField(max_length=200, unique=True)
slug = models.SlugField(max_length=200, unique=True)
author = models.ForeignKey(User, on_delete= models.CASCADE,related_name='amazon_article')
updated_on = models.DateTimeField(auto_now= True)
content = models.TextField()
date_modified = models.DateTimeField(auto_now=True)
date_published = models.DateTimeField(auto_now_add=True)
status = models.CharField(max_length=1,choices=STATUS_CHOICES, default=0)
class Meta:
ordering = ['-date_published']
tags = TaggableManager()
objects = ArticleManager()
def get_absolute_url(self):
return reverse("article", kwargs={"slug": self.slug})