콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
7234 화면

i want to show values of many2many field by jinja 2,

intrested_in = fields.Many2many('intrested.property', string='Intrested In')

class intrestedProperty(models.Model):

    _name = 'intrested.property'

    _rec_name = 'intrested_in'

    intrested_in = fields.Char('Intrested In')

i write a code liike -

INTERESTED IN : ${object.intrested_in}  

Gives output :

INTERESTED IN : intrested.property(1,)

아바타
취소

You need to loop over the records first before printing values. You're literally printing the object (so a record or recordset) instead of a field value.

작성자

How to make a for loop in Jinja?

베스트 답변

Hi,

To display many2many field values in email templates using jinja you have to use the jinja loop check the below example in my example "message" contain a many2many object.

{% for item in message %}


<li>{{{ item.name }}}</li>


 {% endfor %}


here I displaying name field value of many2many object using jinja loop syntax

Regards

아바타
취소
관련 게시물 답글 화면 활동
3
3월 17
8402
1
2월 22
5930
1
2월 19
8582
1
12월 16
5658
1
11월 15
8559