9608 fix choices default

This commit is contained in:
Arthur 2023-03-13 15:12:00 -07:00
parent 7369c772c4
commit 7120a0384c
2 changed files with 6 additions and 2 deletions

View File

@ -644,7 +644,7 @@ class DeviceSerializer(NetBoxModelSerializer):
site = NestedSiteSerializer() site = NestedSiteSerializer()
location = NestedLocationSerializer(required=False, allow_null=True, default=None) location = NestedLocationSerializer(required=False, allow_null=True, default=None)
rack = NestedRackSerializer(required=False, allow_null=True, default=None) rack = NestedRackSerializer(required=False, allow_null=True, default=None)
face = ChoiceField(choices=DeviceFaceChoices, allow_blank=True, default='') face = ChoiceField(choices=DeviceFaceChoices, allow_blank=True, default=lambda: '')
position = serializers.DecimalField( position = serializers.DecimalField(
max_digits=4, max_digits=4,
decimal_places=1, decimal_places=1,
@ -1168,15 +1168,19 @@ class PowerFeedSerializer(NetBoxModelSerializer, CabledObjectSerializer, Connect
) )
type = ChoiceField( type = ChoiceField(
choices=PowerFeedTypeChoices, choices=PowerFeedTypeChoices,
default=lambda: PowerFeedTypeChoices.TYPE_PRIMARY,
) )
status = ChoiceField( status = ChoiceField(
choices=PowerFeedStatusChoices, choices=PowerFeedStatusChoices,
default=lambda: PowerFeedStatusChoices.STATUS_ACTIVE,
) )
supply = ChoiceField( supply = ChoiceField(
choices=PowerFeedSupplyChoices, choices=PowerFeedSupplyChoices,
default=lambda: PowerFeedSupplyChoices.SUPPLY_AC,
) )
phase = ChoiceField( phase = ChoiceField(
choices=PowerFeedPhaseChoices, choices=PowerFeedPhaseChoices,
default=lambda: PowerFeedPhaseChoices.PHASE_SINGLE,
) )
class Meta: class Meta:

View File

@ -99,7 +99,7 @@ class ContactAssignmentSerializer(NetBoxModelSerializer):
object = serializers.SerializerMethodField(read_only=True) object = serializers.SerializerMethodField(read_only=True)
contact = NestedContactSerializer() contact = NestedContactSerializer()
role = NestedContactRoleSerializer(required=False, allow_null=True) role = NestedContactRoleSerializer(required=False, allow_null=True)
priority = extend_schema_field(OpenApiTypes.STR)(ChoiceField(choices=ContactPriorityChoices, allow_blank=True, required=False, default='')) priority = ChoiceField(choices=ContactPriorityChoices, allow_blank=True, required=False, default=lambda: '')
class Meta: class Meta:
model = ContactAssignment model = ContactAssignment