2👍
I’m fairly sure it’s just as simple as if you don’t define that string, it’ll get used to identify the field in a ModelForm
. If you then use various languages on your site, that field wouldn’t have a translated string associated with it.
So you can define a form nice and easy, in forms.py
;
from django import forms
from .models import MyModel
class MyForm(forms.ModelForm):
"""
MyForm is a nice a simple ModelForm using
labels from MyModel.
"""
class Meta:
model = MyModel
fields = ['created', ]
# views.py
from django.views.generic.edit import CreateView
from django.core.urlresolvers import reverse_lazy
from .forms import MyForm
class MyObjCreate(CreateView):
form_class = MyForm
By adding that ugettext
string, it would get pulled in to the message catalog which can then be translated. At least this makes sense from my experience of translations.
Check out the docs, especially this about the class Meta
of a model;
https://docs.djangoproject.com/en/1.7/topics/i18n/translation/#model-verbose-names-values
0👍
it’s needed for translation purpose. If you don’t provide the verbose_name
Django will labelize the field name, but will never be able to translate it. see here for doc https://docs.djangoproject.com/en/1.7/topics/i18n/translation/
- [Answered ]-Client does not support authentication protocol requested by server consider upgrading mysql client
- [Answered ]-Unable to save InMemoryUploadedFile to model in Django