from django.db import models
from django_comments.models import Comment
from django import template
register = template.Library()
@register.filter
def comments_objects(obj):
sc = Comment.objects.filter(object_pk = obj.id, content_type_id = 7).all()
sc = sc.prefetch_related('content_object')
if sc:
text = "%s" % (sc[0].comment)
return text
else:
return 'Нет данных'