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

Fixed default value for boolean fields

This commit is contained in:
Jeremy Stretch
2016-08-18 11:44:40 -04:00
parent 9bdb50c33e
commit 6f44f4245e
3 changed files with 12 additions and 4 deletions

View File

@ -25,7 +25,14 @@ def get_custom_fields_for_model(content_type, bulk_editing=False):
(True, 'True'),
(False, 'False'),
)
field = forms.NullBooleanField(required=cf.required, widget=forms.Select(choices=choices))
if cf.default.lower() in ['true', 'yes', '1']:
initial = True
elif cf.default.lower() in ['false', 'no', '0']:
initial = False
else:
initial = None
field = forms.NullBooleanField(required=cf.required, initial=initial,
widget=forms.Select(choices=choices))
# Date
elif cf.type == CF_TYPE_DATE: