我们从Python开源项目中,提取了以下28个代码示例,用于说明如何使用django.template.defaultfilters.capfirst()。
def __new__(cls, name, bases, attrs): """ Override the default __new__ behavior. """ klass = super(CalAccessMetaClass, cls).__new__(cls, name, bases, attrs) # Cook up an automated verbose name for each model klass_str = str(klass).replace("<class 'calaccess_processed.models.", "") klass_group = klass_str.split(".")[0].upper() klass_table = capfirst(klass._meta.verbose_name_plural) klass_name = "{0}: {1}".format(klass_group, klass_table) # Insert the verbose name into each model's configuration klass._meta.verbose_name = klass_name klass._meta.verbose_name_plural = klass_name # Set the app_label too klass._meta.app_label = "calaccess_processed" # Finish up return klass
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)))
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'), } })
def display_name(self): """ The version of the name for this model we prefer to display on public facing web pages. """ if self.is_flat: return capfirst(self.meta.verbose_name_plural) else: return self.file_name
def form_valid(self, form): try: action = self.state_machine.process_action(form.cleaned_data) except ValidationError as e: for error in e.error_list: form.add_error(None, e) return self.form_invalid(form) else: messages.success(self.request, capfirst(action.description)) return HttpResponseRedirect(action.bug.get_absolute_url())
def inline_formset_data(self): verbose_name = self.opts.verbose_name return json.dumps({ 'name': '#%s' % self.prefix, 'options': { 'prefix': self.prefix, 'addText': ugettext('Add another %(verbose_name)s') % { 'verbose_name': capfirst(verbose_name), }, 'deleteText': ugettext('Remove'), } })