11👍
✅
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.
27👍
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.
👤QUHO
- [Django]-Update model django through kwargs
- [Django]-Authorization Credentials Stripped — django, elastic beanstalk, oauth
- [Django]-Navigation in django
2👍
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' <-----
- [Django]-Django user get_all_permissions() is empty while user_permissions is set
- [Django]-Django Rest Framework make OnetoOne relation ship feel like it is one model
- [Django]-Passing variable urlname to url tag in django template
Source:stackexchange.com