I'm trying to get tags as a queryset to loop through and get another BlogPost that has the same tags, but I get
def get_related_content(self):
related_content = []
if self.tags:
for tag in self.tags:
related_content += BlogDetailPage.objects.live().filter(tags__name=tag)
related_content += OfferDescription.objects.live().filter(tags__name=tag)
else:
return related_content
I get this error:
'_ClusterTaggableManager' object is not iterable
I have also tried to use the django-taggit get_query_set()
method, but it doesn't work, seems not to be included in the wagtail.
def get_related_content(self):
related_content = []
if self.tags:
for tag in self.tags.get_query_set():
related_content += BlogDetailPage.objects.live().filter(tags__name=tag)
related_content += OfferDescription.objects.live().filter(tags__name=tag)
else:
return related_content
'_ClusterTaggableManager' object has no attribute 'get_query_set'
How can I loop over all self.tags
and get other page models that use similar tags?
My Models:
class OfferDescriptionPageTag(TaggedItemBase):
content_object = ParentalKey('OfferDescription', on_delete=models.CASCADE, related_name='tagged_items')
class OfferDescription(Page):
tags = ClusterTaggableManager(through=OfferDescriptionPageTag, blank=True)