翻訳されたフィールドでフォームフィールドのオプションを並べ替えるにはどうすればよいですか?
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 }}
ありがとうございました
編集:
フィールドのオプションをselect
、言語に応じてname_deまたはname_enで並べ替えたいと思います。
<!-- 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>