From 98800c0671bdf1716f393c33f366ab67e335c6eb Mon Sep 17 00:00:00 2001 From: riazanovslv <30866558+riazanovslv@users.noreply.github.com> Date: Fri, 19 Jul 2019 21:25:33 +0300 Subject: [PATCH] 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. --- constance/admin.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/constance/admin.py b/constance/admin.py index 51f68c6..d17b50f 100644 --- a/constance/admin.py +++ b/constance/admin.py @@ -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]: