views:

219

answers:

1

how do i order a the options of a form field by a translated field?

models.py:

class UserProfile(models.Model):
    ...
    country=models.ForeignKey('Country')

class Country(models.Model):
    class Translation(multilingual.Translation):
        name = models.CharField(max_length=60)
    ...

template.html:

{# userprofileform is a standard modelform for UserProfile #}
{{ userprofileform.country }}

thank you

edit:

I want the options of the select field to be ordered by name_de or name_en according to the language:

<!-- English -->
<select>
    <option>Afganistan</option>
    <option>Austria</option>
    <option>Bahamas</option>
</select>

<!-- German (as it is) -->
<select>
    <option>Afganistan</option>
    <option>Österreich</option>
    <option>Bahamas</option>
</select>

<!-- German (as it should be) -->
<select>
    <option>Afganistan</option>
    <option>Bahamaas</option>
    <option>Österreich</option>
</select>
A: 

I don't have any real experience with i18n, so I don't know what's available to you on the backend, but you could use javascript to sort the menus in the browser

Zach
yes, but I'd feel dirty if I did.
Till Backhaus