I have a Django model with several ImageFields.
In the ModelAdmin class, I set save_as save_as = True , which means that on the admin page there is a Save As New button that allows you to duplicate an existing item and save it as new.
However, when this button is used, ImageField are not duplicated and remain empty for the new element.
Looking at the POST request, I see that these fields are empty in the message data.
I thought about overriding the method of saving the model class and copying images from the old object myself. But, as far as I could understand, I can’t say that the object is saved “like new”. I also do not have the identifier of the old element, so I cannot get old images from it.
Can these image fields be duplicated?
Edit: Added sample code on request.
Created a minimalistic application with only one model. A verified issue is still happening.
Example models.py:
from django.db import models class Person(models.Model): face_image = models.ImageField(upload_to='images', null=False, blank=True)
Example admin.py:
from django.contrib import admin from testapp.models import Person class PersonAdmin(admin.ModelAdmin): save_as = True admin.site.register(Person, PersonAdmin)
django
Zappatta Sep 02 '13 at 16:21 2013-09-02 16:21
source share