mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-08 08:38:16 -06:00
Remove second for loop
This commit is contained in:
parent
45ca3282df
commit
318cf5eb60
@ -418,18 +418,15 @@ class BulkImportView(GetReturnURLMixin, BaseMultiObjectView):
|
|||||||
instance.snapshot()
|
instance.snapshot()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# for newly created objects we need to add in the default custom-field
|
# For newly created objects, apply any default custom field values
|
||||||
# values as the form is not posted back so the inital values don't have
|
|
||||||
# an effect.
|
|
||||||
custom_fields = CustomField.objects.filter(
|
custom_fields = CustomField.objects.filter(
|
||||||
object_types=ContentType.objects.get_for_model(self.queryset.model),
|
object_types=ContentType.objects.get_for_model(self.queryset.model),
|
||||||
ui_editable=CustomFieldUIEditableChoices.YES
|
ui_editable=CustomFieldUIEditableChoices.YES
|
||||||
)
|
)
|
||||||
append_fields = [cf for cf in custom_fields if f'cf_{cf.name}' not in record]
|
for cf in custom_fields:
|
||||||
|
|
||||||
for cf in append_fields:
|
|
||||||
field_name = f'cf_{cf.name}'
|
field_name = f'cf_{cf.name}'
|
||||||
record[field_name] = cf.default
|
if field_name not in record:
|
||||||
|
record[field_name] = cf.default
|
||||||
|
|
||||||
# Instantiate the model form for the object
|
# Instantiate the model form for the object
|
||||||
model_form_kwargs = {
|
model_form_kwargs = {
|
||||||
|
Loading…
Reference in New Issue
Block a user