在向数据库添加新条目时,我使用django-model-utils
选择一个选项。
我的模型是这样的:
class Book(models.Model):
STATUS = Choices(
('available', _('Available to borrow')),
('borrowed', _('Borrowed by someone')),
)
status = models.CharField(
max_length=32,
choices=STATUS,
default=STATUS.available,
)
在我的管理页面中,它显示了一个选项的全名(可供借用),但是当我试图使用{{ book.status }}
将此名称添加到HTML模板时,我得到的是available
,而不是Available to borrow
。我试过了,但没用。有什么想法吗,可以把显示文本拉到HTML模板上吗
您应该使用^{} 函数,如文档所示
相关问题 更多 >
编程相关推荐