I am using the comment library. It is built on top of django-contrib-comments
The question is, how can you make sure that when you delete a user, all comments associated with him would be deleted? I would be grateful for any help
I am using the comment library. It is built on top of django-contrib-comments
The question is, how can you make sure that when you delete a user, all comments associated with him would be deleted? I would be grateful for any help
The Comment
--(source) model defined as,
class CommentFlag(models.Model):
user = models.ForeignKey(
settings.AUTH_USER_MODEL, verbose_name=_('user'), related_name="comment_flags",
on_delete=models.CASCADE,
)
# rest of the fields
Note that, the user
field defined with a on_delete=models.CASCADE
which ensures that Django emulates the behavior of the SQL constraint ON DELETE CASCADE
and also deletes the object containing the ForeignKey.
Ref: models.CASCADE