![](/img/trans.png)
[英]Django Foreign Key limit_choice_to with model object filter
[英]limit_choice_to all objects of a particular model classe in a ForeignKey
例
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的查詢語法是什么?)
這項工作不是嗎?
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")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.