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

Does ClearableFileInput work with formsets having empty_permitted set to False? #9

Open
wimfeijen opened this issue Apr 26, 2016 · 0 comments

Comments

@wimfeijen
Copy link

Hello,

Thanks for creating django-file-resubmit!

I have a question: does file resubmit work with form.empty_permitted is False? I suspect that when I use the ClearableFileInput, it does not check empty_permitted. Also, I can clear required images in a formset. Thanks for checking!

`
class ImageForm(forms.ModelForm):
def init(self, _args, *_kwargs):
super(ImageForm, self).init(_args, *_kwargs)
self.fields['image'].required = False

class Meta:
    model = Image
    fields = ['image', ]
    widgets = {
        'image': AdminResubmitImageWidget,
    }

class MyInlineFormSet(BaseInlineFormSet):
def init(self, _args, *_kwargs):
super(MyInlineFormSet, self).init(_args, *_kwargs)
for form in self.forms:
form.empty_permitted = False
break # only for first form

ImageFormSet = inlineformset_factory(
Room,
Image,
form = ImageForm,
formset = MyInlineFormSet,
extra = 5,
min_num = 1,
max_num = 5,
validate_min = True,
)
`

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

No branches or pull requests

1 participant