作者:手机用户2602938575 | 来源:互联网 | 2023-09-18 14:03
classAchievement(MyBaseModel):parent_achievementmodels.ForeignKey(self,blankTrue,null
class Achievement(MyBaseModel):
parent_achievement = models.ForeignKey('self', blank=True, null=True, help_text="An achievement that must be done before this one is achieved") # long name since parent is reserved
I can do :
我能做的:
Achievement.objects.get(pk="1").parent_achievement
which is great. But how do I get all the children?
这是伟大的。但是我怎么才能得到所有的孩子呢?
Achievement.objects.get(pk="1").parent_achievement_set
doesn't work (and probably should have some more notation around it), and I didn't see too much when searching.
不工作(可能应该有更多的符号围绕着它),而且我在搜索时没有看到太多。
Is it possible? Fall into SQL?
是可能的吗?落入SQL ?
2 个解决方案