Локализация Django - перевод моделей через приложения
Я перевожу выбор модели в APP django, но локальные APP не используют локализованную строку.
У меня есть APP с именем base_app со следующей моделью:
class User(AbstractUser):
LIVING_AREA_CHOICES = (
('urban', _('Urban')),
('rural', _('Rural')),
)
name = models.CharField(
_('Option Name'),
null=True, max_length=255,
blank=True
)
def __str__(self):
return self.name or ''
living_area = models.CharField(
_('Living Area'),
choices=LIVING_AREA_CHOICES,
max_length=255,
null=True,
blank=True
) ... other stuff...
Эта модель используется в модельформе forms.py из приложения courses_app (добавлено как внешнее приложение через requirements.txt приложения base_app):
model = get_user_model()
fields = ('username', 'email', 'name', 'first_name', 'last_name', 'image',
'occupation', 'city', 'site', 'biography', 'phone_number','social_facebook',
'social_twitter', 'social_instagram', 'preferred_language', 'neighborhood',
'living_area', 'race', 'birth_date','city', 'gender')
и отображается в profile-edit.html, шаблоне третьего приложения (client_app настроен в .env):
{% with errors=form.living_area.errors %}
<div class="form-group{{ errors|yesno:" has-error,"}}">
<label class="col-xs-12 col-sm-3 col-lg-2 control-label" translate>Living area </label>
<div class="col-xs-12 col-sm-9 col-lg-10">
{{ form.living_area }}
{% for error in errors %}<small class="warning-mark">{{error}}</small>{% endfor %}
</div>
</div>
{% endwith %}
Я уже пытался использовать localized_fields = ('living_area',) в forms.py без успеха. Единственный способ, которым я добился успеха, это добавить строки LIVING_AREA_CHOICES внутри po/mo файлов client_app.
Есть ли способ для шаблона client_app получить переведенную строку из модели base_app?