django-modeltranslation
django-modeltranslation copied to clipboard
Referenced models from forms aren't ordered using the active language
ModelForms referencing other Models through ForeignKey or ManyToManyField that have the field ordering in their Meta classes aren't ordered based on the active language. However, if you go to the admin, for example, and see the list of each of the referenced models, then the lists are well ordered based on the active language.
I don't know if there is a better solution, but I found a workaround, modifying the field's queryset from inside the form constructor (__init__ method). For example:
class FooForm(ModelForm):
def __init__(self, *args, **kwargs):
super(FooForm, self).__init__(*args, **kwargs)
self.fields['category'].queryset = Category.objects.order_by('name')
Thanks for the workaround!