This commit is contained in:
Arthur 2026-07-08 10:45:34 -07:00
parent 6fece9cfc2
commit f9b5df87c5
3 changed files with 6 additions and 5 deletions

View File

@ -199,7 +199,7 @@ class DeviceType(ImageAttachmentsMixin, PrimaryModel, WeightMixin):
clone_fields = (
'manufacturer', 'default_platform', 'u_height', 'is_full_depth', 'subdevice_role', 'airflow', 'weight',
'weight_unit', 'end_of_life',
'weight_unit',
)
prerequisite_models = (
'dcim.Manufacturer',

View File

@ -141,7 +141,7 @@ class ModuleType(ImageAttachmentsMixin, PrimaryModel, WeightMixin):
to_field='module_type'
)
clone_fields = ('profile', 'manufacturer', 'weight', 'weight_unit', 'airflow', 'end_of_life')
clone_fields = ('profile', 'manufacturer', 'weight', 'weight_unit', 'airflow')
prerequisite_models = (
'dcim.Manufacturer',
)

View File

@ -6,7 +6,7 @@ from django.contrib.contenttypes.models import ContentType
from django.contrib.postgres.fields import ArrayField, RangeField
from django.core.exceptions import FieldDoesNotExist
from django.db import transaction
from django.db.models import DateField, JSONField, ManyToManyField, ManyToManyRel
from django.db.models import DateField, DateTimeField, JSONField, ManyToManyField, ManyToManyRel
from django.forms.models import model_to_dict
from django.test import Client
from django.test import TestCase as _TestCase
@ -214,8 +214,9 @@ class ModelTestCase(TestCase):
elif type(value) is IPNetwork:
model_dict[key] = str(value)
# Convert date values to ISO 8601 strings (as rendered by the REST API)
elif type(field) is DateField and value is not None:
# Convert date values to ISO 8601 strings (as rendered by the REST API). DateTimeField
# subclasses DateField, so exclude it here to preserve existing datetime handling.
elif isinstance(field, DateField) and not isinstance(field, DateTimeField) and value is not None:
model_dict[key] = value.isoformat()
# Normalize arrays of numeric ranges (e.g. VLAN IDs or port ranges).