I have a form for a model that contains a ManyToMany relationship to model 
B.
By default, manytomany relationship on forms are SelectMuliple and orders 
them by alphabetical.
How can I order by if they already have a relation?

In my forms.py

class FormA(forms.ModelForm):
    class Meta:
        model = models.A

    def __init___(self, *args, **kwargs):
          super(FormA, self).__init__(*args, **kwargs)
          self.fields["b"].queryset = models.B.objects.order_by(???)

If model B has objects: "a, a1, a2, b, b2"
And model A has a many to many relationship with B's "a, a2, b2"
How can I order the objects so it'll show "a, a2, b2, a1, b" on the form?

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e48671f7-9f21-49c7-b664-0545161d0fa7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to