I am sharing objects between different sites using the Django-sites framework. This works fine because I was able to define a many-to-many relationship within my models.
However, while retrieving the comments (Django-comments) for the objects using the template tag ‘render_comment_list’, I only get those comments which where posted in that particular site. This is expected, but I would like also to get those other comments that were posted for that object which is shared among multiple sites.
Digging into the code of Django-comments, it seems that this is the method causing the ‘problem’:
def get_query_set(self, context):
ctype, object_pk = self.get_target_ctype_pk(context)
if not object_pk:
return self.comment_model.objects.none()
qs = self.comment_model.objects.filter(
content_type = ctype,
object_pk = smart_unicode(object_pk),
site__pk = settings.SITE_ID,
)
My questions are:
- What would be the easiest way to change the behavior so the template tag ‘render_comment_list’ displays all the comments for an object but not just the ones for a particular site?
- Do I need to create another template tag and copy & paste 99% of the Django-comments template tag code?
Thanks
You don’t have to copy and past 99% of the template tag code, just subclass
RenderCommentListNodeand override theget_queryset_methodwhere you identified the problem. Then copy therender_comment_listfunction, but use your child class.