Burak
Burak

Reputation: 5774

How I can get object attributes for different language codes in Django template?

I am using django-transmeta for translation. In the below code, {{ obj.description }} returns the description in the current language of django. What I need is, getting the obj.description_[lang_code]. How can I get it?

{% for lang in languages.all %}
            <div id='{{ lang.code }}'>
                <input type="text" name="description-{{lang.code}}" value='{{ obj.description }}'/>
            </div>
{% endfor %}

Upvotes: 0

Views: 239

Answers (1)

Ahsan
Ahsan

Reputation: 11832

As I understood from your comment you want to get description of specific language in for loop?

then simply write a custom filter like in this way

{{ obj|get_lang_info:lang.code }}

here get_lang_info is custom filter.

Upvotes: 0

Related Questions