Question on 
Stackoverflow: 
http://stackoverflow.com/questions/33486705/define-an-order-for-manytomanyfield-by-through-model-field-with-django

    class ProductRelation(models.Model):
        product_a = models.ForeignKey('Product', related_name='c+')
        product_a_rank = models.PositiveSmallIntegerField('Position')
        product_b = models.ForeignKey('Product', related_name='c+')
        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')


Hello. I have `product` Product instance. How can I get those ordered 
results?
  
product.b_products.all().order_by('product_b_rank')
and  
product.a_products.all().order_by('product_a_rank')

Django 1.8

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/eff8907a-d168-44c5-a48c-66d7ae275006%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to