当前位置: 首页>>代码示例>>Python>>正文


Python defaultfilters.capfirst方法代码示例

本文整理汇总了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 
开发者ID:ra-systems,项目名称:django-ra-erp,代码行数:23,代码来源:admin.py

示例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 
开发者ID:ra-systems,项目名称:django-ra-erp,代码行数:20,代码来源:admin.py

示例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)) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:8,代码来源:helpers.py

示例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'),
            }
        }) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:14,代码来源:helpers.py

示例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) 
开发者ID:ra-systems,项目名称:django-ra-erp,代码行数:13,代码来源:views.py

示例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) 
开发者ID:ra-systems,项目名称:django-ra-erp,代码行数:12,代码来源:admin.py

示例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))) 
开发者ID:Yeah-Kun,项目名称:python,代码行数:10,代码来源:helpers.py

示例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'),
            }
        }) 
开发者ID:Yeah-Kun,项目名称:python,代码行数:14,代码来源:helpers.py

示例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) 
开发者ID:f213,项目名称:education-backend,代码行数:5,代码来源:mixin.py

示例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') 
开发者ID:nesdis,项目名称:djongo,代码行数:4,代码来源:test_capfirst.py

示例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) 
开发者ID:ra-systems,项目名称:django-ra-erp,代码行数:63,代码来源:helpers.py


注:本文中的django.template.defaultfilters.capfirst方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。