Hi guys, from the docs I thought the following should work to get the insertion_order as default (to be recognized by serialiser etc.). The commeted lines are other unsuccessful attemps:
class Thingie(models.Model): obj_id = models.CharField(max_length=32, primary_key=True) children = models.ManyToManyField('Thingie', blank=True, null=True, symmetrical=False, through="OrderedThingieChild") #class Meta: #ordering = ["thingie_from__insertion_order"] class ThingieChild(models.Model): thingie_from = models.ForeignKey(Thingie, related_name='thingie_from') thingie_to = models.ForeignKey(Thingie, related_name='thingie_to') insertion_order = models.IntegerField() #class Meta: #ordering = ["insertion_order"] class OrderedThingieChild(ThingieChild): class Meta: ordering = ordering = ["insertion_order"] proxy = True # Usage: # ---------- import uuid def get_id(): return uuid.uuid1().hex def test_m2m_ordering(): thing_1 = Thingie.objects.create(obj_id=get_id()) thing_2 = Thingie.objects.create(obj_id=get_id()) thing_3 = Thingie.objects.create(obj_id=get_id()) thing_4 = Thingie.objects.create(obj_id=get_id()) OrderedThingieChild.objects.create(thingie_from=thing_1, thingie_to=thing_4, insertion_order=2) OrderedThingieChild.objects.create(thingie_from=thing_1, thingie_to=thing_3, insertion_order=1) OrderedThingieChild.objects.create(thingie_from=thing_1, thingie_to=thing_2, insertion_order=0) How can I specify the default ordering of m2m relations? Cheers, Jan -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.