本文整理汇总了Python中django.template.defaultfilters.title方法的典型用法代码示例。如果您正苦于以下问题:Python defaultfilters.title方法的具体用法?Python defaultfilters.title怎么用?Python defaultfilters.title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.template.defaultfilters
的用法示例。
在下文中一共展示了defaultfilters.title方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: is_proper_title
# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import title [as 别名]
def is_proper_title(value):
if value and value != title(value):
raise ValidationError('Incorrect title')
示例2: clean_name
# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import title [as 别名]
def clean_name(self):
"""
A cleaned up version of the ALL CAPS names that are provided by
the source data.
"""
n = self.name
n = n.strip()
n = n.lower()
n = title(n)
n = n.replace("A. D.", "A.D.")
force_lowercase = ['Of', 'For', 'To', 'By']
for fl in force_lowercase:
s = []
for p in n.split(" "):
if p in force_lowercase:
s.append(p.lower())
else:
s.append(p)
n = " ".join(s)
force_uppercase = [
'Usaf', 'Pac', 'Ca', 'Ad', 'Rcc', 'Cdp', 'Aclu',
'Cbpa-Pac', 'Aka', 'Aflac',
]
for fl in force_uppercase:
s = []
for p in n.split(" "):
if p in force_uppercase:
s.append(p.upper())
else:
s.append(p)
n = " ".join(s)
n = n.replace("Re-Elect", "Re-elect")
n = n.replace("Political Action Committee", "PAC")
return n
示例3: test_title
# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import title [as 别名]
def test_title(self):
self.assertEqual(title('a nice title, isn\'t it?'), "A Nice Title, Isn't It?")
示例4: test_unicode
# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import title [as 别名]
def test_unicode(self):
self.assertEqual(title('discoth\xe8que'), 'Discoth\xe8que')
示例5: test_non_string_input
# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import title [as 别名]
def test_non_string_input(self):
self.assertEqual(title(123), '123')
示例6: getHoverHelp
# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import title [as 别名]
def getHoverHelp(data):
if hasattr(data, 'state_info') and data.state_info:
return {'title': data.state_info}