-1

For creating a dict, i used the following code:

<t t-set="count" t-value="dict()"/>

<t t-foreach="count_obj" t-as="ob">

<t t-set="count" t-esc="count.update({ob.id: ob.name})"/>

</t>

But i am getting a none value.Why? Can anyone help me?Thanks in advance..

1 Answers1

0

shahinsha ummer

You have to specify the value in dict form when you try setting the value [<t t-set="variable" t-value=""/>].

In your example, there is no need to set the variable before the loop with dictionary form it will do nothing.

<t t-foreach="count_obj" t-as="ob">
    <t t-set="count" t-value="{ob.id: ob.name}"/> <!-- Set the Value in form of dictionar -->
    <span t-esc="count"/>
</t>
Dipen Shah
  • 2,396
  • 2
  • 9
  • 21