J
J
JonGalt2017-03-31 15:52:52
Django
JonGalt, 2017-03-31 15:52:52

How to display a field in a Djano template?

There is a model:

class ProjectCompany(models.Model):
    ROLES = (
        ('З', 'Заказчик'),
        ('Т', 'Технический Заказчик'),
        ('П', 'Проектировщик'),
        ('Г', 'Генподрядчик'),
        ('C', 'Субподрядчик'),
    )
    project = models.ForeignKey(Project, null=True)
    company = models.ForeignKey(Company)
    company_role = models.CharField(max_length=2, choices=ROLES, blank=True)
    date_log = models.DateTimeField(verbose_name=u'Дата регистрации', auto_now_add=True)

When outputting to the {{ company_role }} template, a short name is displayed, how to display the full name of the Role of the organization?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rostislav Grigoriev, 2017-03-31
@JonGalt

For the But template
, this is a method, so you need to add parentheses in the view.
instance.get_company_role_display()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question