实施例
class Base():
pass
class A(Base)
parent=models.Foreignkey("self", limit_choices_to=(all members of the B class)
class B(Base)
parent=models.Foreignkey("self", limit_choices_to=(all members of the A class)
limit_choices_to的查询语法是什么,只能得到 某一类的对象?)
答案 0 :(得分:1)
这不会起作用吗?
class Base(Model):
parent=models.Foreignkey("self")
class Meta:
abstract = True
class A(Base):
parent=models.Foreignkey("B")
class B(Base):
parent=models.Foreignkey("A")