Skip to content

Commit 3be3bbe

Browse files
committed
Upgrade DRF to v3.15
1 parent 0dedf60 commit 3be3bbe

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

netbox/dcim/api/serializers_/devicetypes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import decimal
2+
13
from django.utils.translation import gettext as _
24
from rest_framework import serializers
35

@@ -22,7 +24,7 @@ class DeviceTypeSerializer(NetBoxModelSerializer):
2224
max_digits=4,
2325
decimal_places=1,
2426
label=_('Position (U)'),
25-
min_value=0,
27+
min_value=decimal.Decimal(0),
2628
default=1.0
2729
)
2830
subdevice_role = ChoiceField(choices=SubdeviceRoleChoices, allow_blank=True, required=False, allow_null=True)

netbox/netbox/api/serializers/base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@ def __init__(self, *args, nested=False, fields=None, **kwargs):
2727
self.nested = nested
2828
self._requested_fields = fields
2929

30+
# Disable validators for nested objects (which already exist)
31+
if self.nested:
32+
self.validators = []
33+
3034
# If this serializer is nested but no fields have been specified,
3135
# default to using Meta.brief_fields (if set)
32-
if nested and not fields:
36+
if self.nested and not fields:
3337
self._requested_fields = getattr(self.Meta, 'brief_fields', None)
3438

3539
super().__init__(*args, **kwargs)

netbox/virtualization/models/virtualmachines.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import decimal
2+
13
from django.contrib.contenttypes.fields import GenericRelation
24
from django.core.exceptions import ValidationError
35
from django.core.validators import MinValueValidator
@@ -112,7 +114,7 @@ class VirtualMachine(ContactsMixin, RenderConfigMixin, ConfigContextModel, Prima
112114
null=True,
113115
verbose_name=_('vCPUs'),
114116
validators=(
115-
MinValueValidator(0.01),
117+
MinValueValidator(decimal.Decimal(0.01)),
116118
)
117119
)
118120
memory = models.PositiveIntegerField(

netbox/vpn/api/serializers_/tunnels.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ class TunnelSerializer(NetBoxModelSerializer):
4747
group = TunnelGroupSerializer(
4848
nested=True,
4949
required=False,
50-
allow_null=True
50+
allow_null=True,
51+
default=None
5152
)
5253
encapsulation = ChoiceField(
5354
choices=TunnelEncapsulationChoices

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ django-rq==2.10.2
1212
django-taggit==5.0.1
1313
django-tables2==2.7.0
1414
django-timezone-field==6.1.0
15-
djangorestframework==3.14.0
15+
djangorestframework==3.15.1
1616
drf-spectacular==0.27.1
1717
drf-spectacular-sidecar==2024.3.4
1818
feedparser==6.0.11

0 commit comments

Comments
 (0)