1👍
Dude, if you want to make a translation of what is known as verbose_name, ideally u use the django internationalization.
The documentation in the following link: https://docs.djangoproject.com/en/dev/topics/i18n/translation/
1👍
I finally found a way, using the work described by Beau Simensen : http://srcmvn.com/blog/2013/01/15/django-advanced-model-choice-field/ who modified ModelChoiceField to return (value,label,model) instead of (value,label).
So far, seems to work OK for me.
from django.forms import models
from django.forms.fields import ChoiceField
class AdvancedModelChoiceIterator(models.ModelChoiceIterator):
def choice(self, obj):
return (self.field.prepare_value(obj), self.field.label_from_instance(obj), obj)
class AdvancedModelChoiceField(models.ModelChoiceField):
def _get_choices(self):
if hasattr(self, '_choices'):
return self._choices
return AdvancedModelChoiceIterator(self)
choices = property(_get_choices, ChoiceField._set_choices)
- [Answered ]-Testing with Django: how to display all characters when using assertEqual with json object?
- [Answered ]-Django edit static content on live site
- [Answered ]-Page not save forms data in django
- [Answered ]-Django: Error-MultipleObjectsReturned while generating a generic list view
- [Answered ]-How can I get an image URL from an image field in an InlineFormset?
Source:stackexchange.com