Upgrade DRF to v3.15
This commit is contained in:
parent
0dedf602e8
commit
3be3bbe534
|
@ -1,3 +1,5 @@
|
|||
import decimal
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
from rest_framework import serializers
|
||||
|
||||
|
@ -22,7 +24,7 @@ class DeviceTypeSerializer(NetBoxModelSerializer):
|
|||
max_digits=4,
|
||||
decimal_places=1,
|
||||
label=_('Position (U)'),
|
||||
min_value=0,
|
||||
min_value=decimal.Decimal(0),
|
||||
default=1.0
|
||||
)
|
||||
subdevice_role = ChoiceField(choices=SubdeviceRoleChoices, allow_blank=True, required=False, allow_null=True)
|
||||
|
|
|
@ -27,9 +27,13 @@ class BaseModelSerializer(serializers.ModelSerializer):
|
|||
self.nested = nested
|
||||
self._requested_fields = fields
|
||||
|
||||
# Disable validators for nested objects (which already exist)
|
||||
if self.nested:
|
||||
self.validators = []
|
||||
|
||||
# If this serializer is nested but no fields have been specified,
|
||||
# default to using Meta.brief_fields (if set)
|
||||
if nested and not fields:
|
||||
if self.nested and not fields:
|
||||
self._requested_fields = getattr(self.Meta, 'brief_fields', None)
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import decimal
|
||||
|
||||
from django.contrib.contenttypes.fields import GenericRelation
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.validators import MinValueValidator
|
||||
|
@ -112,7 +114,7 @@ class VirtualMachine(ContactsMixin, RenderConfigMixin, ConfigContextModel, Prima
|
|||
null=True,
|
||||
verbose_name=_('vCPUs'),
|
||||
validators=(
|
||||
MinValueValidator(0.01),
|
||||
MinValueValidator(decimal.Decimal(0.01)),
|
||||
)
|
||||
)
|
||||
memory = models.PositiveIntegerField(
|
||||
|
|
|
@ -47,7 +47,8 @@ class TunnelSerializer(NetBoxModelSerializer):
|
|||
group = TunnelGroupSerializer(
|
||||
nested=True,
|
||||
required=False,
|
||||
allow_null=True
|
||||
allow_null=True,
|
||||
default=None
|
||||
)
|
||||
encapsulation = ChoiceField(
|
||||
choices=TunnelEncapsulationChoices
|
||||
|
|
|
@ -12,7 +12,7 @@ django-rq==2.10.2
|
|||
django-taggit==5.0.1
|
||||
django-tables2==2.7.0
|
||||
django-timezone-field==6.1.0
|
||||
djangorestframework==3.14.0
|
||||
djangorestframework==3.15.1
|
||||
drf-spectacular==0.27.1
|
||||
drf-spectacular-sidecar==2024.3.4
|
||||
feedparser==6.0.11
|
||||
|
|
Loading…
Reference in New Issue