Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot merge models with subclassed ImageField or FileField: "file not sent" error #95

Closed
int-ua opened this issue Feb 27, 2016 · 3 comments
Labels

Comments

@int-ua
Copy link
Contributor

int-ua commented Feb 27, 2016

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.

@saxix saxix added the bug label Nov 13, 2016
@int-ua
Copy link
Contributor Author

int-ua commented Mar 31, 2017

Note to self: it's not limited to Grappelli, fails without it too.

@int-ua
Copy link
Contributor Author

int-ua commented Mar 31, 2017

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()

@int-ua int-ua changed the title Cannot merge models with subclassed ImageField: "file not sent" error Cannot merge models with subclassed ImageField or FileField: "file not sent" error Mar 31, 2017
@int-ua
Copy link
Contributor Author

int-ua commented Mar 31, 2017

I can imagine two possible workarounds:

  • changing adminactions.merge.merge.raw_widget so that it won't return TextWidget if isinstance(field, models.FileField). This breaks value selections before merging.
  • writing custom to_python method for the subclassed field that will reconstruct UploadedFile from str

saxix added a commit that referenced this issue Apr 1, 2017
…inactions into int-ua-feature/issue_95

* 'feature/issue_95' of git://github.com/int-ua/django-adminactions:
  Trying to add tests for #95
@saxix saxix closed this as completed in f61862f Apr 1, 2017
saxix added a commit that referenced this issue Apr 1, 2017
* int-ua-feature/issue_95:
  fixes #95
  Trying to add tests for #95
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants