Unable to make correct migrations in Django

I cannot make correct migrations with one specific fields image_two in my Django Project. I have also configured Django-Rest and all this is connected to AWS. Endpoint is looking alright and I am getting correct url from image_one and image_two. But I don't know how to create a column in database for storage this image URL.

Yes, I have read documentation from ImageKIT and they said:

ImageSpecFields, on the other hand, are virtual—they add no fields to your database and don’t require a database. This is handy for a lot of reasons, but it means that the path to the image file needs to be programmatically constructed based on the source image and the spec.

In ImageKIT there is also ProcessedImageField, but this is not an option for me, because I have to also save in database source image and send it to AWS S3.

from django.db import models
from imagekit import ImageSpec, register
from imagekit.models import ImageSpecField
from imagekit.processors import ResizeToFill
from imagekit.utils import get_field_info


class ImageTest (models.Model):
    
        name = models.CharField(max_length=50, blank=False)
        added_at = models.DateTimeField(auto_now_add=True)
        image_one = models.ImageField(null=True, blank=False)
        new_width = models.PositiveIntegerField(blank=False)
        new_height = models.PositiveIntegerField(blank=False)
        image_two = ImageSpecField(source='image_source',
                                       id='myapp:imagetest:resizeme',)
    
        class ResizeMe(ImageSpec):
    
            format = 'JPEG'
            options = {'quality': 80}
    
            @property
            def processors(self):
                model, field_name = get_field_info(self.source)
                return [ResizeToFill(new_width, new_height)]
    
        register.generator('myapp:imagetest:resizeme', ResizeMe)

Do you have any ideas? I will be very grateful for any comments and help. :)

Back to Top