SHARE
TWEET

Untitled

a guest Oct 23rd, 2017 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. styles = style.models.Style.objects.filter(brand_account=self.brand_account, deleted=0)
  2. style_ids = styles.values_list('id', flat=True)
  3.  
  4. style_colors = style.models.StyleColor.objects.filter(deleted=0, style_id__in=style_ids)
  5. style_color_ids = style_colors.values_list('id', flat=True)
  6.  
  7. product_upc = size.models.ProductUPC.objects.filter(style_color_id__in=style_color_ids,
  8.                                                     style=django.db.models.OuterRef(
  9.                                                         django.db.models.OuterRef('pk')))
  10.  
  11. styles = styles.annotate(product_upc=django.db.models.Subquery(product_upc.values('product_upc')[:1]))
RAW Paste Data
Top