我试图在博客中添加对评论的回复,每次提交回复时,尽管我已将评论过滤到{{1 }}
这里是reply = None
:
views.py
这里是models.py
class Post(models.Model):
----------------------------------------
title = models.CharField(max_length=100)
likes = models.ManyToManyField(
User, related_name='liked', blank=True)
slug = models.SlugField(blank=True, null=True, max_length=120)
class Comment(models.Model):
post = models.ForeignKey(
Post, on_delete=models.CASCADE)
user = models.ForeignKey(
User, on_delete=models.CASCADE)
reply = models.ForeignKey(
'Comment', on_delete=models.CASCADE, null=True, related_name="replies")
content = models.TextField(max_length=160)
我已经修改了视图,并且不确定是否需要为与评论相同的内容创建基于类的视图