Skip to content

Pre-warm not working on Django with empty log #150

@kuipumu

Description

@kuipumu

Hi, I deployed my Django 2.2.2 project online, so I disabled the option to create images on demand and set the rendition keys for my images on the settings of my project, then I set a post save action to create all the images I need, but after the model is saved there is no images created by the post save. I followed the procedure that shows on the documentation of the app. I also tried to just work with the images on demand but every time I create a new object I just get a 500 error on my Apache server. What I am doing wrong?, here is the code I added to pre warm the images.

settings.py:

VERSATILEIMAGEFIELD_SETTINGS = {
    'cache_length': 2592000,
    'cache_name': 'versatileimagefield_cache',
    'jpeg_resize_quality': 70,
    'sized_directory_name': '__sized__',
    'filtered_directory_name': '__filtered__',
    'placeholder_directory_name': '__placeholder__',
    # Whether or not to create new images on-the-fly. Set this to `False` for
    # speedy performance but don't forget to 'pre-warm' to ensure they're
    # created and available at the appropriate URL.
    'create_images_on_demand': False,
    'image_key_post_processor': None,
    'progressive_jpeg': True
}

VERSATILEIMAGEFIELD_RENDITION_KEY_SETS = {
    'posten_thumbnail': [
        ('thumbnail_1_crop', 'crop__128x72'),
        ('thumbnail_2_crop', 'crop__384x216'),
        ('thumbnail_3_crop', 'crop__640x360'),
        ('thumbnail_4_crop', 'crop__512x288'),
        ('thumbnail_5_crop', 'crop__768x432'),
        ('thumbnail_6_crop', 'crop__1280x720'),
        ('thumbnail_7_crop', 'crop__1920x1080'),
        ('thumbnail_8_crop', 'crop__600x400'),
        ('thumbnail_9_crop', 'crop__800x600'),
        ('thumbnail_9_crop', 'crop__300x200'),
        ('thumbnail_10_crop', 'crop__1400x750'),
    ],
    'postes_thumbnail': [
        ('thumbnail_1_crop', 'crop__128x72'),
        ('thumbnail_2_crop', 'crop__384x216'),
        ('thumbnail_3_crop', 'crop__640x360'),
        ('thumbnail_4_crop', 'crop__512x288'),
        ('thumbnail_5_crop', 'crop__768x432'),
        ('thumbnail_6_crop', 'crop__1280x720'),
        ('thumbnail_7_crop', 'crop__1920x1080'),
        ('thumbnail_8_crop', 'crop__600x400'),
        ('thumbnail_9_crop', 'crop__800x600'),
        ('thumbnail_9_crop', 'crop__300x200'),
        ('thumbnail_10_crop', 'crop__1400x750'),
    ],
    'image_thumbnail':[
        ('thumbnail_1_crop', 'crop__128x72'),
        ('thumbnail_2_crop', 'crop__384x216'),
        ('thumbnail_3_crop', 'crop__512x288'),
        ('thumbnail_4_crop', 'crop__768x432'),
    ]
}

models.py

@receiver(models.signals.post_save, sender=Image)
def warm_Image_thumbnail_images(sender, instance, **kwargs):
    thumbnail_img_warmer = VersatileImageFieldWarmer(
        instance_or_queryset=instance,
        rendition_key_set='image_thumbnail',
        image_attr='thumbnail'
    )
    num_created, failed_to_create = thumbnail_img_warmer.warm()

@receiver(models.signals.post_save, sender=PostEN)
def warm_PostEN_thumbnail_images(sender, instance, **kwargs):
    thumbnail_img_warmer = VersatileImageFieldWarmer(
        instance_or_queryset=instance,
        rendition_key_set='posten_thumbnail',
        image_attr='thumbnail'
    )
    num_created, failed_to_create = thumbnail_img_warmer.warm()

@receiver(models.signals.post_save, sender=PostES)
def warm_PostES_thumbnail_images(sender, instance, **kwargs):
    thumbnail_img_warmer = VersatileImageFieldWarmer(
        instance_or_queryset=instance,
        rendition_key_set='postes_thumbnail',
        image_attr='thumbnail'
    )
    num_created, failed_to_create = thumbnail_img_warmer.warm()

When I run these post save signals it doesn't work, but these same codes work when I do it from Django shell.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions