From 634634d65b08a85d00c2e9e126e886b2f97b8852 Mon Sep 17 00:00:00 2001 From: Brian Tiemann Date: Mon, 18 Nov 2024 13:36:31 -0500 Subject: [PATCH] Coerce _abs_weight to int to prevent disagreement with PositiveBigIntegerField deserialization --- netbox/dcim/models/mixins.py | 2 +- netbox/utilities/conversion.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/netbox/dcim/models/mixins.py b/netbox/dcim/models/mixins.py index d4a05699c..4f38bebea 100644 --- a/netbox/dcim/models/mixins.py +++ b/netbox/dcim/models/mixins.py @@ -37,7 +37,7 @@ class WeightMixin(models.Model): # Store the given weight (if any) in grams for use in database ordering if self.weight and self.weight_unit: - self._abs_weight = to_grams(self.weight, self.weight_unit) + self._abs_weight = int(to_grams(self.weight, self.weight_unit)) else: self._abs_weight = None diff --git a/netbox/utilities/conversion.py b/netbox/utilities/conversion.py index cd75c3c17..be95df14f 100644 --- a/netbox/utilities/conversion.py +++ b/netbox/utilities/conversion.py @@ -10,7 +10,7 @@ __all__ = ( ) -def to_grams(weight, unit): +def to_grams(weight, unit) -> float: """ Convert the given weight to kilograms. """