django - 为什么较低的内置过滤器在 Django 模板 2.2 中不起作用?
问题描述
使用Django v2.2
模板的内置过滤器。
我的模板如下所示:
{% load i18n %}{% blocktrans with site_name=current_site.organization.name site_domain=current_site.name %}Hello from {{ site_name }}!
You're receiving this e-mail because your email is subscribed to receiving notification when a Quotation is Pending PO Release.
{{ quote_type }}
{{ quote_type|lower }}
- Quotation: {{ display_quotation_number }}
- PO Date: {{ po_date_display }} (New)
{% endblocktrans %}
{% blocktrans with site_name=current_site.organization.name site_domain=current_site.name %}Thank you for using {{ site_name }}!
{{ site_domain }}{% endblocktrans %}
我可以肯定地说,这{{ quote_type }}
肯定会打印出一些东西。{{ quote_type|lower }}
什么都不打印。
我做错了什么?
我确定过滤器是内置的;见https://docs.djangoproject.com/en/2.2/ref/templates/builtins/#lower
更新
这是我目前的工作,它有效
extra_context = self.lower_quote_type(extra_context)
quotation.email_people(
recipient_list=recipient_list,
extra_context=extra_context,
)
def lower_quote_type(self, extra_context):
# @makeAnIssue temp workard for #1334 but try to permanently fix it elegantly
if "quote_type" in extra_context:
extra_context["quote_type"] = extra_context["quote_type"].lower()
return extra_context
然后这个工作
{% load i18n %}{% blocktrans with site_name=current_site.organization.name site_domain=current_site.name %}Hello from {{ site_name }}!
You're receiving this e-mail because your email is subscribed to receiving notification when a Quotation is Pending PO Release.
{{ quote_type }} # this correctly shows up as lower case
- Quotation: {{ display_quotation_number }}
- PO Date: {{ po_date_display }} (New)
{% endblocktrans %}
{% blocktrans with site_name=current_site.organization.name site_domain=current_site.name %}Thank you for using {{ site_name }}!
{{ site_domain }}{% endblocktrans %}
解决方案
推荐阅读
- ios - TabBar 更改选定的背景颜色
- python - ValueError: 操作数不能与形状 (8,) (2,) Curve_fit() 一起广播
- java - MongoDB 找到一个特定的文档?
- api - 使用 Sitecore JSS 的 API 安全性
- sql-server - 如何在 between 子句中使用 varchar 日期字段 - SQL Server 2012
- java - RmiRegistry 在运行单元测试时创建了多次
- neo4j - 使用 Cypher 通过图的所有有效路径
- php - php说有些结果不是未定义的,而有些是
- phpspreadsheet - 如何更改工作表标题颜色背景?
- azure-devops - 我可以制定 Team Foundation Server 2018 的交付计划吗?