Created
March 25, 2020 16:26
-
-
Save mumin91/f74d5b01290c0b9423a052ffb7658f52 to your computer and use it in GitHub Desktop.
Recursive chain comment model in Django
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Comment(models.Model): | |
| comment = models.CharField(max_length=300) | |
| blogpost = models.ForeignKey(Blogpost, on_delete=models.CASCADE) | |
| commenter = models.ForeignKey(get_user_model(), on_delete=models.CASCADE) | |
| created_at = models.DateTimeField(auto_now_add=True) | |
| updated_at = models.DateTimeField(auto_now=True) | |
| parent = models.ForeignKey('self', null=True, blank=True, related_name='replies', on_delete=models.CASCADE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment