繁体   English   中英

limit_choice_to外键中特定模型类的所有对象

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM