Advertisement
Guest User

Untitled

a guest
Jun 16th, 2015
272
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. >>> len(connection.queries)
  2. 44
  3. >>> lista = []
  4. >>> ordens = Ordered.objects.all()
  5. >>> for ordem in ordens:
  6. ...     for o in ordem.dealership.all():
  7. ...         lista.append(o.dealership)
  8. ...
  9. >>> lista
  10. [u'd1', u'd2', u'd2', u'd3', u'd1', u'd3', u'd2']
  11. >>> len(connection.queries)
  12. 49
  13. >>> lista = []
  14. >>> ordens = Ordered.objects.all().prefetch_related('dealership')
  15. >>> for ordem in ordens:
  16. ...     for o in ordem.dealership.all():
  17. ...         lista.append(o.dealership)
  18. ...
  19. >>> lista
  20. [u'd1', u'd2', u'd2', u'd3', u'd1', u'd3', u'd2']
  21. >>> len(connection.queries)
  22. 51
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement