Django ModelForm shortcut capture

In my model, I:

title = models.CharField(verbose_name="eBay Listing Title",max_length=56) 

Using ModelForm, the label is displayed as "EBay List Title" (capital E). I use

 {{ field.label_tag }} 

in a form template (in a loop) to display labels.

How can I get a shortcut to correctly display the lowercase first letter?

+8
django django-forms
source share
2 answers

You can override the shortcut in the form

eg:

 class YourForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(YourForm, self).__init__(*args, **kwargs) self.fields['title'].label = "eBay Listing Title" class Meta: model = YourModel 
+10
source share

Go to the label argument http://docs.djangoproject.com/en/dev/ref/forms/fields/#label

An uppercase letter is just the default - replacing underscores with spaces and uppercase letters if you don't pass anything.

Example from the docs:

 >>> class CommentForm(forms.Form): ... name = forms.CharField(label='Your name') 
+3
source share

All Articles