Upload an image without altering model (using ModelForm)

Hello, I have a model called Image:

class Image(models.Model, GenericCheckForDelete):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    url = models.CharField(validators=[URLValidator()])
    alt_en = models.CharField()
    description = models.CharField(blank=True, null=True)
    alt_cs = models.CharField()

    class Meta:
        managed = False
        db_table = 'planner"."image'

    def __str__(self) -> str:
        return self.alt_en

I want to implement a way to upload an image without adding Image/FileField to the model. I want to do it using ModelForm like this:

class ImageForm(forms.ModelForm):
    image_file = forms.FileField(label="Image file", required=True)

    class Meta:
        model = Image
        exclude = []

class ImageAdmin(UniversalModelAdmin):
    def image_preview(self, obj):
        Add image preview based on url field value
            return format_html(f'<img src="{obj.url}" style="max-width:100px; max-height:100px"/>')
            return None

    form = ImageForm
    list_display = [field.name for field in Image._meta.fields] + ["image_preview"]
    fields = [field.name for field in Image._meta.fields if field.name != "id"] + ["image_preview", "image_file"]
    readonly_fields = ["image_preview"]

But in ModelForm, there is no upload_to attribute. How do I upload images and save them to Amazon S3? Is there such an option in admin interface? Thanks for your help

If you don’t have a Model with a file field, how are you going to track / use that file?

If it’s truly a situation that for Django it’s “save the file and forget about it”, you would need to write the file yourself to its storage location.

I’m not sure how you would integrate that into the Admin - if I had to try and do this, I’d be looking at overriding the ModelAdmin.save_model method to handle this.