本文整理匯總了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}