A drop-in replacement for django's ImageField that provides a flexible, intuitive and easily-extensible interface for quickly creating new images from the one assigned to the field.
Hi,
First, thanks for the lib!
In VersatileImageFieldWarmer.warm:
total = self.queryset.count() * len(self.size_key_list) for a, instance in enumerate(self.queryset, start=1): for b, size_key in enumerate(self.size_key_list, start=1):
Since we are iterating on the queryset, there's not need to use .count on the previous line. So could be replaced by:
total = len(self.queryset) * len(self.size_key_list) for a, instance in enumerate(self.queryset, start=1):
Also, and since the doc recommends it this way:
person_img_warmer = VersatileImageFieldWarmer( instance_or_queryset=instance, rendition_key_set='person_headshot', image_attr='headshot' )
if we pass an instance, it's transformed to a queryset by doing:
if isinstance(instance_or_queryset, Model): queryset = instance_or_queryset.__class__._default_manager.filter( pk=instance_or_queryset.pk )
making a query to the db again. I guess it can be easily replaced with:
if isinstance(instance_or_queryset, Model): queryset =[instance_or_queryset]
since we won't do queryset.count().
Unless I miss something, happy to open a PR with the changes
Hi, First, thanks for the lib! In VersatileImageFieldWarmer.warm:
total = self.queryset.count() * len(self.size_key_list) for a, instance in enumerate(self.queryset, start=1): for b, size_key in enumerate(self.size_key_list, start=1):
Since we are iterating on the queryset, there's not need to use .count on the previous line. So could be replaced by:
total = len(self.queryset) * len(self.size_key_list) for a, instance in enumerate(self.queryset, start=1):
Also, and since the doc recommends it this way:
person_img_warmer = VersatileImageFieldWarmer( instance_or_queryset=instance, rendition_key_set='person_headshot', image_attr='headshot' )
if we pass an instance, it's transformed to a queryset by doing:
if isinstance(instance_or_queryset, Model): queryset = instance_or_queryset.__class__._default_manager.filter( pk=instance_or_queryset.pk )
making a query to the db again. I guess it can be easily replaced with:if isinstance(instance_or_queryset, Model): queryset =[instance_or_queryset]
since we won't do queryset.count().Unless I miss something, happy to open a PR with the changes