我的模特:
Class A(Orderable, Slugged):
a = models.CharField(max_length=250, null=True, blank=True)
class Meta:
ordering = ("_order",)
Class B(Orderable, Slugged):
a = models.ForeignKey(A, null=True, blank=True)
b = models.CharField(max_length=250, null=True, blank=True)
class Meta:
ordering = ("_order",)
order_with_respect_to = "a"
Class C(Orderable, Slugged):
b = models.ForeignKey(B, null=True, blank=True)
c = models.CharField(max_length=250, null=True, blank=True)
class Meta:
ordering = ("_order",)
order_with_respect_to = "b__a"
我怎么能做到这一点? 我想要“C”类order_with_respect_to“A”类。 将不胜感激。
答案 0 :(得分:1)
您可以尝试从C.Meta
继承A.Meta
:
class C(Orderable, Slugged):
...
class Meta(A.Meta):
pass # C.order_with_respect_to is equal to A.order_with_respect_to