tangentlabs/django-oscar — pull request #406 by andrefsp (2012-12-04 15:20:58+00:00)
Title: Missing Product Image handling. 

In case of a Product don't have a ProductImage it's possible now to
mimic a Image object so that we can handle this situations more
elegantly.

class Product(models.Model):
missing_image = None

def get_missing_image(self):
# We can use this to return a missing image base on some
# criteria e.g product_class attribute

:: Example
class MissingProductImage(self):

def fullsize_url(self):
return "/static/%s/not_found.jpg" % self.product_class

def __init__(self, product_class=None):
self.product_class = product_class

class Product(models.Model):
def get_missing_image(self):
return MissingProductImage(product_class=self.product_class)