Question

I am using django-modeltranslation for translation of my content.

If the value of a translated field is not set for a language then it automatically takes the value of the default language.

However, is there a way to know if value for a given language has been set?

If for example title_fr is not set, obj.title_fr will return the value of obj.title. How to know if the french version has been defined?

Était-ce utile?

La solution

You can access original field value with instance.__dict__['title_fr'].

However, you probably want to customize fallback_values option:

https://django-modeltranslation.readthedocs.org/en/latest/usage.html#fallback-values

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top