如何在Django过滤器中转换字段?

时间:2019-07-19 14:56:23

标签: django ajax django-models django-views translate

我从客户那里得到价值。它们进入Russian

如何在过滤器中替换它们?

有必要将输入值转换为English,或将字段值转换为Russian(django.po中已经有转换)。 Django有可能吗?还是我需要与客户做些事情?

models.py

BORROWER_CATEGORY_STANDARD = _('standard')
BORROWER_CATEGORY_PAYROLL = _('payroll')

BORROWER_CATEGORY_CHOICES = (
   (BORROWER_CATEGORY_STANDARD, _('Standard')),
   (BORROWER_CATEGORY_PAYROLL, _('Payroll')),
)

views.py

request.POST-俄罗斯值字典

cps = cps.filter(borrower_category=request.POST.get('borrower_category'))

设置

LANGUAGE_CODE = 'ru'

LANGUAGES = (
    ('ru', gettext('Russian')),
    ('kk', gettext('Kazakh')),
)

MODELTRANSLATION_DEFAULT_LANGUAGE = 'ru'

USE_I18N = True

'django.template.context_processors.i18n',

SOLID_I18N_USE_REDIRECTS = True

0 个答案:

没有答案