K
K
kolibry12015-05-07 15:10:06
Django
kolibry1, 2015-05-07 15:10:06

How to translate Label value in python django?

It is necessary that the name of the form is displayed in the template. the record {{ form.last_name.label }} outputs in English (as written in the forms and model). Is there a way to translate the titles? and where/how is it done?
directly in the template through {% trans %} does not work.
thanks in advance)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2015-05-07
@kolibry1

app/models.py

#-*- coding:utf-8 -*-
from django.utils.translation import ugettext_lazy as _

class Registration(models.Model):
    ...
    create = models.DateTimeField(_(u"#Создано"), auto_now_add=True, blank=True, null=True)

    class Meta:
        verbose_name = _(u'#Регистрация')
        verbose_name_plural = _(u'#Подтверждение регистрации')

A
Andrey K, 2015-05-07
@mututunus

https://docs.djangoproject.com/en/1.8/topics/i18n/...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question