문제

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