diff --git a/netbox/netbox/views/generic/bulk_views.py b/netbox/netbox/views/generic/bulk_views.py index d7d28b95f5d..bac5c6ea98c 100644 --- a/netbox/netbox/views/generic/bulk_views.py +++ b/netbox/netbox/views/generic/bulk_views.py @@ -734,7 +734,6 @@ def _rename_objects(self, form, selected_objects): renamed_pks = [] for obj in selected_objects: - # Take a snapshot of change-logged models if hasattr(obj, 'snapshot'): obj.snapshot() @@ -748,7 +747,7 @@ def _rename_objects(self, form, selected_objects): except re.error: obj.new_name = obj.name else: - obj.new_name = obj.name.replace(find, replace) + obj.new_name = (obj.name or '').replace(find, replace) renamed_pks.append(obj.pk) return renamed_pks @@ -783,6 +782,10 @@ def post(self, request): ) return redirect(self.get_return_url(request)) + except IntegrityError as e: + messages.error(self.request, ", ".join(e.args)) + clear_events.send(sender=self) + except (AbortRequest, PermissionsViolation) as e: logger.debug(e.message) form.add_error(None, e.message)