From 93ac0b77c94b2e761176d07c92ba0fa699ba76e3 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Fri, 6 Jan 2023 16:10:30 -0500 Subject: [PATCH] Fixes #11379: Fix TypeError exception when bulk editing custom date fields --- netbox/netbox/views/generic/bulk_views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netbox/netbox/views/generic/bulk_views.py b/netbox/netbox/views/generic/bulk_views.py index 75416f097..ab3e8f100 100644 --- a/netbox/netbox/views/generic/bulk_views.py +++ b/netbox/netbox/views/generic/bulk_views.py @@ -494,7 +494,7 @@ class BulkEditView(GetReturnURLMixin, BaseMultiObjectView): return get_permission_for_model(self.queryset.model, 'change') def _update_objects(self, form, request): - custom_fields = getattr(form, 'custom_fields', []) + custom_fields = getattr(form, 'custom_fields', {}) standard_fields = [ field for field in form.fields if field not in list(custom_fields) + ['pk'] ] @@ -532,13 +532,13 @@ class BulkEditView(GetReturnURLMixin, BaseMultiObjectView): setattr(obj, name, form.cleaned_data[name]) # Update custom fields - for name in custom_fields: + for name, customfield in custom_fields.items(): assert name.startswith('cf_') cf_name = name[3:] # Strip cf_ prefix if name in form.nullable_fields and name in nullified_fields: obj.custom_field_data[cf_name] = None elif name in form.changed_data: - obj.custom_field_data[cf_name] = form.fields[name].prepare_value(form.cleaned_data[name]) + obj.custom_field_data[cf_name] = customfield.serialize(form.cleaned_data[name]) obj.full_clean() obj.save()