product Product objects get pk 1124 related product related_items all

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
product = Product.objects.get(pk=1124)
related = product.related_items.all()
>>> for i in related:
... print i.unit_price
...
205.00
205.00
205.00
0.00
122.00
94.00
94.00
94.00
myarray = []
for i in related:
myarray.append(i)
sorted_array = myarray.sort(lambda x,y: cmp(x.unit_price, y.unit_price))
>>> print sorted_array
None