From 5a1f6f6dd96dccad1acc8d848c8b5f5bdd844a8a Mon Sep 17 00:00:00 2001 From: Grokzen Date: Fri, 18 May 2018 21:33:50 +0200 Subject: [PATCH] Fix the default creation value for weight --- startup_scripts/20_custom_fields.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/startup_scripts/20_custom_fields.py b/startup_scripts/20_custom_fields.py index 494d425..3ddf97a 100644 --- a/startup_scripts/20_custom_fields.py +++ b/startup_scripts/20_custom_fields.py @@ -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)