Fixes #22395: Remove unused save() override on ManagedFileForm

The method wrote uploaded files to disk via a raw open(), but no code
path reached it. Its only subclass, ScriptFileForm, overrode save() to
write through django-storages and explicitly skipped the base via
super(ManagedFileForm, self).save(). With the override gone, that call
simplifies back to a plain super().save(). A leftover from #18680, which
moved both upload paths onto django-storages but left the form-level
write in place.
This commit is contained in:
Jason Novinger 2026-06-15 16:21:46 +02:00 committed by Jeremy Stretch
parent d7de863681
commit b7de62610f
2 changed files with 1 additions and 11 deletions

View File

@ -114,15 +114,6 @@ class ManagedFileForm(SyncedDataMixin, NetBoxModelForm):
return self.cleaned_data
def save(self, *args, **kwargs):
# If a file was uploaded, save it to disk
if self.cleaned_data['upload_file']:
self.instance.file_path = self.cleaned_data['upload_file'].name
with open(self.instance.full_path, 'wb+') as new_file:
new_file.write(self.cleaned_data['upload_file'].read())
return super().save(*args, **kwargs)
class ConfigFormMetaclass(forms.models.ModelFormMetaclass):

View File

@ -112,5 +112,4 @@ class ScriptFileForm(ManagedFileForm):
data = self.cleaned_data['upload_file']
storage.save(filename, data)
# need to skip ManagedFileForm save method
return super(ManagedFileForm, self).save(*args, **kwargs)
return super().save(*args, **kwargs)