Python django.template.defaultfilters.capfirst() Examples
The following are 15
code examples of django.template.defaultfilters.capfirst().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django.template.defaultfilters
, or try the search function
.
Example #1
Source File: admin.py From django-ra-erp with GNU Affero General Public License v3.0 | 6 votes |
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
Example #2
Source File: admin.py From django-ra-erp with GNU Affero General Public License v3.0 | 6 votes |
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
Example #3
Source File: helpers.py From bioforum with MIT License | 5 votes |
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))
Example #4
Source File: helpers.py From bioforum with MIT License | 5 votes |
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'), } })
Example #5
Source File: views.py From django-ra-erp with GNU Affero General Public License v3.0 | 5 votes |
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)
Example #6
Source File: admin.py From django-ra-erp with GNU Affero General Public License v3.0 | 5 votes |
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)
Example #7
Source File: helpers.py From Hands-On-Application-Development-with-PyCharm with MIT License | 5 votes |
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))
Example #8
Source File: helpers.py From Hands-On-Application-Development-with-PyCharm with MIT License | 5 votes |
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'), } })
Example #9
Source File: helpers.py From python with Apache License 2.0 | 5 votes |
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)))
Example #10
Source File: helpers.py From python with Apache License 2.0 | 5 votes |
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'), } })
Example #11
Source File: helpers.py From python2017 with MIT License | 5 votes |
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)))
Example #12
Source File: helpers.py From python2017 with MIT License | 5 votes |
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'), } })
Example #13
Source File: mixin.py From education-backend with MIT License | 5 votes |
def _natural_datetime(self, date): local = timezone.localtime(date) return capfirst(naturalday(local)) + ' ' + self._time(local)
Example #14
Source File: test_capfirst.py From djongo with GNU Affero General Public License v3.0 | 5 votes |
def test_capfirst(self): self.assertEqual(capfirst('hello world'), 'Hello world')
Example #15
Source File: helpers.py From django-ra-erp with GNU Affero General Public License v3.0 | 4 votes |
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)