Skip to content

mixins

django_spire.comment.mixins

CommentModelMixin

Bases: Model

comments = GenericRelation('comment.Comment', related_query_name='comment', editable=False) class-attribute instance-attribute

Meta

abstract = True class-attribute instance-attribute

add_comment

Source code in django_spire/comment/mixins.py
def add_comment(
        self,
        user: User,
        information: str,
        parent: int | Comment | None = None
):
    if isinstance(parent, Comment):
        parent = parent.pk

    return self.comments.create(
        information=information,
        user=user,
        parent_id=parent
    )