تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
5611 أدوات العرض

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)

الصورة الرمزية
إهمال
الكاتب أفضل إجابة

Found it myself. It's apparently


prod = products & things  #intersection

For More information on operations refer to this Recordset Operations
الصورة الرمزية
إهمال
أفضل إجابة

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)

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
مايو 21
2680
1
أبريل 22
1845
1
مارس 21
5770
1
يوليو 19
7911
1
مايو 16
4407