Reputation: 1
what are self and parent? this is part of a comment app
models.py
class Comment(models.Model):
user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE, blank=True, null=True)
email = models.EmailField(blank=True)
parent = models.ForeignKey('self', on_delete=models.CASCADE, null=True, blank=True)
Upvotes: 0
Views: 37
Reputation: 1103
because a comment can be another comment's child, self
stands for class Comment
here.
for example:
father=Comment(user=...)
father.save()
son=Comment(user=...)
son.parent=father
son.save()
Upvotes: 1