tangentlabs/django-oscar — pull request #681 by abbas123456 (2013-05-18 22:29:54+00:00)
Title: Product primary_image function calls database twice

The following code results in two database queries, one for getting the count of all images and one for selecting the first image:

```
def primary_image(self):
images = self.images.all()
if images.count():
return images[0]
```

As this is called pretty much all over the site (mini basket, product listings etc), I suggest changing it so that the operation uses only one query to achieve the same logic.