Skip to content

Commit 5822729

Browse files
14637 update to Django 5 (#14675)
* 14637 update to Django 5 * 14637 fix tests * 14637 remove extra assignment * Syntax tweak --------- Co-authored-by: Jeremy Stretch <[email protected]>
1 parent 8e20581 commit 5822729

File tree

6 files changed

+11
-9
lines changed

6 files changed

+11
-9
lines changed

base_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ bleach
44

55
# The Python web framework on which NetBox is built
66
# https://docs.djangoproject.com/en/stable/releases/
7-
Django<5.0
7+
Django<5.1
88

99
# Django middleware which permits cross-domain API requests
1010
# https://github.com/adamchainz/django-cors-headers/blob/main/CHANGELOG.rst

netbox/core/tests/test_filtersets.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
from datetime import datetime
1+
from datetime import datetime, timezone
22

33
from django.test import TestCase
4-
from django.utils import timezone
5-
64
from utilities.testing import ChangeLoggedFilterSetTests
75
from ..choices import *
86
from ..filtersets import *

netbox/dcim/models/cables.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,14 @@ def clean(self):
317317
super().clean()
318318

319319
# Check for existing termination
320-
existing_termination = CableTermination.objects.exclude(cable=self.cable).filter(
320+
qs = CableTermination.objects.filter(
321321
termination_type=self.termination_type,
322322
termination_id=self.termination_id
323-
).first()
323+
)
324+
if self.cable.pk:
325+
qs = qs.exclude(cable=self.cable)
326+
327+
existing_termination = qs.first()
324328
if existing_termination is not None:
325329
raise ValidationError(
326330
f"Duplicate termination found for {self.termination_type.app_label}.{self.termination_type.model} "

netbox/dcim/models/devices.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ def vc_interfaces(self, if_master=True):
10981098
10991099
:param if_master: If True, return VC member interfaces only if this Device is the VC master.
11001100
"""
1101-
filter = Q(device=self)
1101+
filter = Q(device=self) if self.pk else Q()
11021102
if self.virtual_chassis and (self.virtual_chassis.master == self or not if_master):
11031103
filter |= Q(device__virtual_chassis=self.virtual_chassis, mgmt_only=False)
11041104
return Interface.objects.filter(filter)

netbox/extras/models/configs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def get_config_context(self):
182182

183183
if not hasattr(self, 'config_context_data'):
184184
# The annotation is not available, so we fall back to manually querying for the config context objects
185-
config_context_data = ConfigContext.objects.get_for_object(self, aggregate_data=True)
185+
config_context_data = ConfigContext.objects.get_for_object(self, aggregate_data=True) or []
186186
else:
187187
# The attribute may exist, but the annotated value could be None if there is no config context data
188188
config_context_data = self.config_context_data or []

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
bleach==6.1.0
2-
Django==4.2.8
2+
Django==5.0.1
33
django-cors-headers==4.3.1
44
django-debug-toolbar==4.2.0
55
django-filter==23.5

0 commit comments

Comments
 (0)