Cannot merge models with subclassed ImageField or FileField: "file not sent" error
int-ua opened this issue · 3 comments
If a model that I want to merge have a field that is not an original ImageFIeld, but was subclassed from it, for example:
class ImageField2(ImageField):
pass
then default MergeForm stops working if resulting instance contains a link in this field. Is it a bug? Can I somehow subclass MergeForm to state which field needs to be just copied instead of trying to upload an image?
It's an old project with django-thumbs
, in case it can help.
Note to self: it's not limited to Grappelli, fails without it too.
The error occurs on this line, FileFields also affected https://github.com/django/django/blob/d3d12fc11da56e4ea8af37a22a9a0aa6579ab2d5/django/forms/forms.py#L405 in django.forms.forms.BaseForm._clean_fields()
I can imagine two possible workarounds:
- changing
adminactions.merge.merge.raw_widget
so that it won't returnTextWidget
if isinstance(field, models.FileField)
. This breaks value selections before merging. - writing custom
to_python
method for the subclassed field that will reconstructUploadedFile
fromstr