Fix the default creation value for weight

This commit is contained in:
Grokzen 2018-05-18 21:33:50 +02:00
parent 170bf4e03d
commit 5a1f6f6dd9
1 changed files with 1 additions and 4 deletions

View File

@ -60,10 +60,7 @@ with open('/opt/netbox/initializers/custom_fields.yml', 'r') as stream:
choice, _ = CustomFieldChoice.objects.get_or_create(
field=custom_field,
value=choice_details['value'],
defaults={'weight': idx * 10}
)
# Add weight after initial creation to fix a bug if you use the same 'value'
# for multiple custom fields.
choice.weight = choice_details.get('weight', idx * 10)
choice.save()
print("🔧 Created custom field", cf_name)