0
class PositionModel(models.Model):
xpos = models.IntegerField()
ypos = models.IntegerField()
def relative(self, x, y):
self.__class__.objects.filter(xpos = self.xpos + x,
ypos = self.ypos + y)
class Meta:
abstract = True
本示例允许您在多个不同模型中继承PositionModel,然后使用relative(x,y)函数根据模型执行查询的孩子。Django:使用抽象父模型中子模型的管理器
Django是否有其他一些首选的方法在使用孩子的管理器的抽象模型中编写函数?