From ca86c60499f2ee862cccdbbcb1138cfc57f2dc2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregor=20M=C3=BCllegger?= Date: Thu, 28 Nov 2013 12:15:52 +0100 Subject: [PATCH] Django 1.6 changed the MultiWidget.needs_multipart_form attribute into a property. We didn't plan for that in floppify code yet. We check now for properties which makes it compatible with Django 1.6 and more futureproof. Part of a Fix for #387. --- djadmin2/forms.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/djadmin2/forms.py b/djadmin2/forms.py index ef3e33f..554560b 100644 --- a/djadmin2/forms.py +++ b/djadmin2/forms.py @@ -28,7 +28,13 @@ def _copy_attributes(original, new_widget, attributes): for attr in attributes: original_value = getattr(original, attr) original_value = deepcopy(original_value) - setattr(new_widget, attr, original_value) + + # Don't set the attribute if it is a property. In that case we can be + # sure that the widget class is taking care of the calculation for that + # property. + old_value_on_new_widget = getattr(new_widget.__class__, attr, None) + if not isinstance(old_value_on_new_widget, property): + setattr(new_widget, attr, original_value) def _create_widget(widget_class, copy_attributes=(), init_arguments=()):