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?

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top