From 467ae90a76940e55c6177a85cb23559715a9c684 Mon Sep 17 00:00:00 2001 From: Florian Scherf Date: Mon, 25 Nov 2024 16:48:26 +0100 Subject: [PATCH] fix: incompatibility with djangocms-versioning-filer 1.3 was fixed When used with djangocms-versioning-filer, the `FileAdminChangeForm` might not have a file field due to missing permissions. Since djangocms-versioning-filer 1.3 the constructor of `FileAdminChangeForm` crashes when opening the change URL of a published image. This patch fixes this issue by adding a check whether the file field is present before overriding it. Signed-off-by: Florian Scherf --- filer/admin/fileadmin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/filer/admin/fileadmin.py b/filer/admin/fileadmin.py index 48d06442b..517f57380 100644 --- a/filer/admin/fileadmin.py +++ b/filer/admin/fileadmin.py @@ -35,7 +35,8 @@ class Meta: def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.fields["file"].widget = forms.FileInput() + if "file" in self.fields: + self.fields["file"].widget = forms.FileInput() def clean(self): from ..validation import validate_upload