Yan Tian
Yan Tian

Reputation: 397

`django_comments_xtd` shared by multiple class models

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 ?

Upvotes: 0

Views: 44

Answers (1)

Distroyer
Distroyer

Reputation: 11

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

Upvotes: 0

Related Questions