Example
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)
What would be the query syntax for limit_choices_to, to get only the objects of a certain class?)
Wouldn't this work instead ?
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")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.