def get_default_variant(self):
        """
        Returns the default variant, which is supposed to be displayed within
        the product view.

        This is either a selected variant or the first added variant. If the
        product has no variants it is None.
        """
        cache_key = "%s-default-variant-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX, self.id)
        default_variant = cache.get(cache_key)

        if default_variant is not None:
            return default_variant

        if self.default_variant is not None:
            default_variant = self.default_variant
        elif self.is_product_with_variants():
            try:
                default_variant = self.variants.filter(active=True)[0]
            except __HOLE__:
                return None

        cache.set(cache_key, default_variant)
        return default_variant
dataset/ETHPy150Open diefenbach/django-lfs/lfs/catalog/models.py/Product.get_default_variant