1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

8749 clone custom fields

This commit is contained in:
Arthur
2022-11-17 10:25:50 -08:00
committed by Jeremy Stretch
parent ef7c66de34
commit f7150645a1
9 changed files with 45 additions and 5 deletions

View File

@@ -121,6 +121,15 @@ class CloningMixin(models.Model):
if is_taggable(self):
attrs['tags'] = [tag.pk for tag in self.tags.all()]
# check custom fields
if hasattr(self, 'custom_field_data'):
from extras.models import CustomField
for field in CustomField.objects.get_for_model(self):
if field.is_cloneable:
value = self.custom_field_data.get(field.name)
attrs[f'cf_{field.name}'] = field.deserialize(value)
return attrs