Django ModelForm label customization
If somebody else are looking for it at this time(2016 - Django 1.9)
It works just like this for me:
labels = { "title": "Rule Title", "other_field": "Other Title" }
With out the lazy import.
Did you import following?
from django.utils.translation import ugettext_lazy as _
ugettext
, ugettext_lazy
are used to specify translation strings. _
is used to save typings.
I have Django 1.6 and I have the SAME problems as 'GregoryR'. I didn't try importing _ugettext_lazy as _. Instead, I did this the easy way (last line):
def __init__(self, *args, **kwargs): super(ModelForm, self).__init__(*args, **kwargs) self.css_class = "rule" self.fields['title'].label = 'Rule Title' <-----