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 <jstretch@netboxlabs.com>
This commit is contained in:
Arthur Hanson
2024-01-05 10:30:04 -08:00
committed by GitHub
parent 8e20581da7
commit 58227293f3
6 changed files with 11 additions and 9 deletions

View File

@@ -317,10 +317,14 @@ class CableTermination(ChangeLoggedModel):
super().clean()
# Check for existing termination
existing_termination = CableTermination.objects.exclude(cable=self.cable).filter(
qs = CableTermination.objects.filter(
termination_type=self.termination_type,
termination_id=self.termination_id
).first()
)
if self.cable.pk:
qs = qs.exclude(cable=self.cable)
existing_termination = qs.first()
if existing_termination is not None:
raise ValidationError(
f"Duplicate termination found for {self.termination_type.app_label}.{self.termination_type.model} "