Ir al contenido
Menú
Se marcó esta pregunta

I have two objects of model 'product.template' called 'things' and 'products'

things have product.template(29, 15, 14, 12, 11)

products have product.template(15, 29, 18, 10, 21, 12)

I want to make a third object of product.template having only common products in these two objects. ie,

third object prod should only have product.template(29, 15, 12)

Avatar
Descartar
Autor Mejor respuesta

Found it myself. It's apparently


prod = products & things  #intersection

For More information on operations refer to this Recordset Operations
Avatar
Descartar
Mejor respuesta

third_object = []

for o_things in objects:

for o_prod in products:

if o_things.id == o_prod.id:

thrid_object.append(o_things.id)

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
may 21
2774
1
abr 22
1963
1
mar 21
5919
1
jul 19
8033
1
may 16
4526