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

validation #23

Open
marojenka opened this issue Jul 23, 2017 · 6 comments · May be fixed by #49
Open

validation #23

marojenka opened this issue Jul 23, 2017 · 6 comments · May be fixed by #49

Comments

@marojenka
Copy link
Contributor

hi,
love the app.
Work with validators was strange for me since app sends all data as one list while validators usually expect single element so I used custom interface for validators defined as an argument for MultiuploadField.
Since version 1.11 django claim to use default validator for ImageField and in one of early releases they actually set it and it broke MultiImageField and such.
Problem is the same: MultiuploadField send list to Image validators while they expect single element so something like

    def run_validators(self, value):
        value = value or []
        for item in value:
            super(MultiUploadMetaField, self).run_validators(item)

will allow MultiUploadMetaField to work out of box.
cheers o/

@illagrenan
Copy link

Thanks @marojenka for your solution, I had the same issue. To expand your post, here is my full solution to run validators with multiple files:

# my_project/fields
from multiupload.fields import MultiImageField

class ValidatedMultiImageField(MultiImageField):
    def run_validators(self, value):
        value = value or []

        for item in value:
            super().run_validators(item)
# usage in forms.py:
class FooModelForm(forms.ModelForm):
    attachments = ValidatedMultiImageField()
    # ...

@ghost
Copy link

ghost commented Jan 17, 2020

Thanks for hint with validator. Do you guys have an example how to use multiupload with formsets?
I spent on that solution 2 days and it doesn't work to me and I didn't found code with combination multiupload and formsets.

Thanks a lot
K

@marojenka
Copy link
Contributor Author

My general approach with formsets is not to use formsets. It's hard for me to help you without seeing your code but I don't think it's a proper place for it.

@dreaquil
Copy link

dreaquil commented Nov 6, 2021

Thanks @marojenka, I came across this as well. Can we create a PR for fixing this?

@marojenka
Copy link
Contributor Author

@dreaquil hello,
it's been a while and I don't use this app so I'm not entirely sure if this is still a case. What version of Django and this app are you using?
I suspect that #41 might be related.

@dreaquil
Copy link

dreaquil commented Nov 8, 2021

Hi @marojenka,

I'm currently on Django 3.2 and django-multiupload 0.6.1. You're right, #41 is identical as it is the issue that lead me to this one.

DmytroLitvinov added a commit to DmytroLitvinov/django-multiupload that referenced this issue Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants