class User(models.Model):
username = models.Charfield()
class Topic(models.Model):
# Posted by
user = models.ForeignKey(User)
class Reply(models.Model):
topic = models.ForeignKey(Topic)
# Respondent
user = models.ForeignKey(User)
Now we need to query all the replies to posts posted by a user
user = User.objects.get(pk=5)
replies = Reply. objects.filter(topic.user.id==user.id)
Always reports an error:
SyntaxError: keyword can't be an expression
May I ask? How to deal with it so that you can get all the replies.
殘留の回憶2019-08-21 09:35:22
I’m not familiar with django, so I can’t help you. I broke 0 replies,~~