下面是我的模型,我使用的是InheritanceManager
的django-model-utils
。我决定字段user
在子类中,因为我需要通过user.child1_set.all()
这样的关系访问Child
子类。你知道吗
class Mother(models.Model):
objects = InheritanceManager()
class Child1(Mother):
user = models.ForiegnKey(User)
class Child2(Mother):
user = models.ForiegnKey(User)
问题是,当我想从Mother
类开始进行查询时,似乎没有任何查询使它成为可能。你知道吗
我试过这些密码。你知道吗
Mother.objects.filter(user=SOMEUSER)
Mother.objects.filter(child1__user=SOMEUSER)
Mother.objects.select_subclasses().filder(user=SOMEUSER)
Mother.objects.select_subclasses().filder(child1__user=SOMEUSER)
如有任何建议,将不胜感激。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐