In my model I have;
title = models.CharField(verbose_name="eBay Listing Title",max_length=56)
Using a ModelForm the label shows as "EBay Listing Title" (capital E). I'm using
{{ field.label_tag }}
on the form template (in a loop) to display the labels.
How can I get the label to show correctly with a lowercase first letter?
You can override the label in the form
for example:
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
Pass in the label
argument
http://docs.djangoproject.com/en/dev/ref/forms/fields/#label
The capitalization is just a default -- replacing underscores with spaces and capitalizing if you don't pass in anything.
Example from docs:
>>> class CommentForm(forms.Form):
... name = forms.CharField(label='Your name')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With