`django_comments_xtd` shared by multiple class models

46 views Asked by At

I have a Django+Wagtail blog site integrated with django_comments_xtd as below:

class PostDetail(Page):
    ...


class Comment(XtdComment):
    page = models.ForeignKey('PostDetail', on_delete=models.CASCADE)

    def save(self, *args, **kwargs):
        if self.user:
            self.user_name = self.user.username
        self.page = PostDetail.objects.get(pk=self.object_pk)
        super(Comment, self).save(*args, **kwargs)

Now I am about to create another class model class SurveyPoll(Page):,

How can I apply the same Comment to the newly-created model? Should I create another comment model ?

1

There are 1 answers

0
Distroyer On

You have many options for that, simplist and cleanest is to inherit from both (Page, Comment)