mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-08 16:48:16 -06:00
Use .sub
instead of .replace
for bulk renaming
This commit is contained in:
parent
07364abf9e
commit
15c6296f91
@ -35,6 +35,7 @@ from .models import (
|
||||
InventoryItem, Platform, PowerOutlet, PowerOutletTemplate, PowerPort, PowerPortTemplate, Rack, RackGroup,
|
||||
RackReservation, RackRole, Region, Site, VirtualChassis,
|
||||
)
|
||||
from re import sub
|
||||
|
||||
|
||||
class BulkRenameView(View):
|
||||
@ -59,7 +60,7 @@ class BulkRenameView(View):
|
||||
|
||||
if form.is_valid():
|
||||
for obj in selected_objects:
|
||||
obj.new_name = obj.name.replace(form.cleaned_data['find'], form.cleaned_data['replace'])
|
||||
obj.new_name = sub(form.cleaned_data['find'], form.cleaned_data['replace'], obj.name)
|
||||
|
||||
if '_apply' in request.POST:
|
||||
for obj in selected_objects:
|
||||
|
Loading…
Reference in New Issue
Block a user