本文整理汇总了Python中django.template.defaultfilters.capfirst方法的典型用法代码示例。如果您正苦于以下问题:Python defaultfilters.capfirst方法的具体用法?Python defaultfilters.capfirst怎么用?Python defaultfilters.capfirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.template.defaultfilters
的用法示例。
在下文中一共展示了defaultfilters.capfirst方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_enhanced_obj_title
# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import capfirst [as 别名]
def get_enhanced_obj_title(self, obj):
request = CrequestMiddleware.get_request()
links = []
pk_attname = self.model._meta.pk.attname
pk = getattr(obj, pk_attname)
main_url = False
if self.has_change_permission(request, obj):
url = reverse('%s:%s_%s_change' % (app_settings.RA_ADMIN_SITE_NAME, self.model._meta.app_label,
self.model._meta.model_name),
args=(quote(pk),),
current_app=self.admin_site.name)
if not main_url: main_url = url
view_link = '<a href="%s" data-popup="tooltip" title="%s" data-placement="bottom">' \
' <i class="fas fa-edit"></i> </a>' % (
url, capfirst(_('change')))
links.append(view_link)
links = "<span class='go-to-change-form'>%s</span>" % ''.join(links) + ''
obj_link_title = "<a href='%s'>%s</a>" % (main_url, obj.title)
return mark_safe('%s %s' % (obj_link_title, links))
return obj.title
示例2: lookups
# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import capfirst [as 别名]
def lookups(self, request, model_admin):
vals = ()
val_list = []
cs = ContentType.objects.filter(logentry__action_flag__in=[1, 2, 3]).distinct()
exclude_function = RaPermissionWidgetExclude()
for c in cs:
model = c.model_class()
if model:
if not exclude_function(model):
# vals += ((c.pk, force_text(model._meta.verbose_name_plural)),)
val_list.append({
'name': capfirst(force_text(model._meta.verbose_name_plural)),
'value': ((c.pk, capfirst(force_text(model._meta.verbose_name_plural))),)
})
ordered_list = dictsort(val_list, 'name')
for o in ordered_list:
vals += o['value']
return vals
示例3: label_tag
# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import capfirst [as 别名]
def label_tag(self):
attrs = {}
if not self.is_first:
attrs["class"] = "inline"
label = self.field['label']
return format_html('<label{}>{}:</label>', flatatt(attrs), capfirst(label))
示例4: inline_formset_data
# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import capfirst [as 别名]
def inline_formset_data(self):
verbose_name = self.opts.verbose_name
return json.dumps({
'name': '#%s' % self.formset.prefix,
'options': {
'prefix': self.formset.prefix,
'addText': gettext('Add another %(verbose_name)s') % {
'verbose_name': capfirst(verbose_name),
},
'deleteText': gettext('Remove'),
}
})
示例5: get_report_title
# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import capfirst [as 别名]
def get_report_title(cls):
"""
:return: The report title
"""
# title = 'TITLE'
title = ''
if cls.report_title:
title = cls.report_title
elif cls.page_title:
title = cls.page_title
return capfirst(title)
示例6: get_stats_icon
# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import capfirst [as 别名]
def get_stats_icon(self, obj):
url = reverse('%s:%s_%s_view' % (app_settings.RA_ADMIN_SITE_NAME, self.model._meta.app_label,
self.model._meta.model_name),
args=(quote(obj.pk),),
current_app=self.admin_site.name)
view_link = '<a href="%s" data-popup="tooltip" title="%s %s" data-placement="bottom"> ' \
'<i class="fas fa-chart-line"></i> </a>' % (
url, capfirst(_('Statistics for')), obj.title)
return mark_safe(view_link)
示例7: label_tag
# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import capfirst [as 别名]
def label_tag(self):
attrs = {}
if not self.is_first:
attrs["class"] = "inline"
label = self.field['label']
return format_html('<label{}>{}:</label>',
flatatt(attrs),
capfirst(force_text(label)))
示例8: inline_formset_data
# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import capfirst [as 别名]
def inline_formset_data(self):
verbose_name = self.opts.verbose_name
return json.dumps({
'name': '#%s' % self.formset.prefix,
'options': {
'prefix': self.formset.prefix,
'addText': ugettext('Add another %(verbose_name)s') % {
'verbose_name': capfirst(verbose_name),
},
'deleteText': ugettext('Remove'),
}
})
示例9: _natural_datetime
# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import capfirst [as 别名]
def _natural_datetime(self, date):
local = timezone.localtime(date)
return capfirst(naturalday(local)) + ' ' + self._time(local)
示例10: test_capfirst
# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import capfirst [as 别名]
def test_capfirst(self):
self.assertEqual(capfirst('hello world'), 'Hello world')
示例11: admin_get_app_list
# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import capfirst [as 别名]
def admin_get_app_list(request, admin_site):
"""
:param request: Copied from AdminSite.index() djagno v1.8
:param admin_site:
:return:
"""
from ra.base.app_settings import RA_MENU_HIDE_MODELS, RA_ADMIN_SITE_NAME
app_dict = {}
for model, model_admin in admin_site._registry.items():
app_label = model._meta.app_label
has_module_perms = model_admin.has_module_permission(request)
is_model_hidden = '%s_%s' % (app_label, model.__name__.lower()) in RA_MENU_HIDE_MODELS
if has_module_perms and not is_model_hidden:
perms = model_admin.get_model_perms(request)
# Check whether user has any perm for this module.
# If so, add the module to the model_list.
if True in perms.values():
info = (RA_ADMIN_SITE_NAME, app_label, model._meta.model_name)
model_dict = {
'name': capfirst(model._meta.verbose_name_plural),
'object_name': model._meta.object_name,
'perms': perms,
'model_class': model,
}
if perms.get('view', False) or perms.get('change', False) or perms.get('add', False):
try:
model_dict['admin_url'] = reverse('%s:%s_%s_changelist' % info, current_app=admin_site.name)
except NoReverseMatch:
pass
if perms.get('add', False):
try:
model_dict['add_url'] = reverse('%s:%s_%s_add' % info, current_app=admin_site.name)
except NoReverseMatch:
pass
if app_label in app_dict:
app_dict[app_label]['models'].append(model_dict)
else:
app_dict[app_label] = {
'name': apps.get_app_config(app_label).verbose_name,
'app_label': app_label,
'app_url': reverse(
'%s:app_list' % RA_ADMIN_SITE_NAME,
kwargs={'app_label': app_label},
current_app=admin_site.name,
),
'has_module_perms': has_module_perms,
'models': [model_dict],
}
# Sort the apps alphabetically.
app_list = list(app_dict.values())
app_list.sort(key=lambda x: x['name'].lower())
# Sort the models alphabetically within each app.
for app in app_list:
app['models'].sort(key=lambda x: x['name'])
return order_apps(app_list)