ConstanceForm save method tweak (#333)

We need to store the actual name of the file, which the storage's save method provides. Otherwise, if we upload a new file with the same name as the already stored file has, the Constance config will keep a link to the old file.
This commit is contained in:
riazanovslv 2019-07-19 21:25:33 +03:00 committed by Camilo Nova
parent 1e751f1afa
commit 98800c0671

View file

@ -139,8 +139,7 @@ class ConstanceForm(forms.Form):
def save(self):
for file_field in self.files:
file = self.cleaned_data[file_field]
default_storage.save(file.name, file)
self.cleaned_data[file_field] = file.name
self.cleaned_data[file_field] = default_storage.save(file.name, file)
for name in settings.CONFIG:
if getattr(config, name) != self.cleaned_data[name]: