mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 01:41:22 -06:00
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 django.utils.translation import gettext as _
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
@ -22,7 +24,7 @@ class DeviceTypeSerializer(NetBoxModelSerializer):
|
|||||||
max_digits=4,
|
max_digits=4,
|
||||||
decimal_places=1,
|
decimal_places=1,
|
||||||
label=_('Position (U)'),
|
label=_('Position (U)'),
|
||||||
min_value=0,
|
min_value=decimal.Decimal(0),
|
||||||
default=1.0
|
default=1.0
|
||||||
)
|
)
|
||||||
subdevice_role = ChoiceField(choices=SubdeviceRoleChoices, allow_blank=True, required=False, allow_null=True)
|
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.nested = nested
|
||||||
self._requested_fields = fields
|
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,
|
# If this serializer is nested but no fields have been specified,
|
||||||
# default to using Meta.brief_fields (if set)
|
# 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)
|
self._requested_fields = getattr(self.Meta, 'brief_fields', None)
|
||||||
|
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import decimal
|
||||||
|
|
||||||
from django.contrib.contenttypes.fields import GenericRelation
|
from django.contrib.contenttypes.fields import GenericRelation
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.core.validators import MinValueValidator
|
from django.core.validators import MinValueValidator
|
||||||
@ -112,7 +114,7 @@ class VirtualMachine(ContactsMixin, RenderConfigMixin, ConfigContextModel, Prima
|
|||||||
null=True,
|
null=True,
|
||||||
verbose_name=_('vCPUs'),
|
verbose_name=_('vCPUs'),
|
||||||
validators=(
|
validators=(
|
||||||
MinValueValidator(0.01),
|
MinValueValidator(decimal.Decimal(0.01)),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
memory = models.PositiveIntegerField(
|
memory = models.PositiveIntegerField(
|
||||||
|
@ -47,7 +47,8 @@ class TunnelSerializer(NetBoxModelSerializer):
|
|||||||
group = TunnelGroupSerializer(
|
group = TunnelGroupSerializer(
|
||||||
nested=True,
|
nested=True,
|
||||||
required=False,
|
required=False,
|
||||||
allow_null=True
|
allow_null=True,
|
||||||
|
default=None
|
||||||
)
|
)
|
||||||
encapsulation = ChoiceField(
|
encapsulation = ChoiceField(
|
||||||
choices=TunnelEncapsulationChoices
|
choices=TunnelEncapsulationChoices
|
||||||
|
@ -12,7 +12,7 @@ django-rq==2.10.2
|
|||||||
django-taggit==5.0.1
|
django-taggit==5.0.1
|
||||||
django-tables2==2.7.0
|
django-tables2==2.7.0
|
||||||
django-timezone-field==6.1.0
|
django-timezone-field==6.1.0
|
||||||
djangorestframework==3.14.0
|
djangorestframework==3.15.1
|
||||||
drf-spectacular==0.27.1
|
drf-spectacular==0.27.1
|
||||||
drf-spectacular-sidecar==2024.3.4
|
drf-spectacular-sidecar==2024.3.4
|
||||||
feedparser==6.0.11
|
feedparser==6.0.11
|
||||||
|
Loading…
Reference in New Issue
Block a user