class ProductRelation(models.Model):
product_a = models.ForeignKey('Product')
product_a_rank = models.PositiveSmallIntegerField('Position')
product_b = models.ForeignKey('Product')
product_b_rank = models.PositiveSmallIntegerField('Postition')
class Product(models.Model):
b_products = models.ManyToManyField('self', through=ProductRelation, symmetrical=False,
through_fields=('product_a', 'product_b'),
related_name='a_products',
)
你好。我有product
个产品实例。我怎样才能得到那些有序的结果?product.b_products.all().order_by('product_b_rank')
以及product.a_products.all().order_by('product_a_rank')
迪亚戈1.8
使用双下划线来
order_by
相关字段:编辑:
^{pr2}$相关问题 更多 >
编程相关推荐