From 8c9bb73ff79cf8136a5d809ce02e951e3390edcc Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 4 Dec 2024 19:51:22 -0500 Subject: [PATCH] Fixes #17810: Disable DRF's native unique constraint checks --- netbox/netbox/api/serializers/base.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/netbox/netbox/api/serializers/base.py b/netbox/netbox/api/serializers/base.py index 8115fe020a5..6cd4e573890 100644 --- a/netbox/netbox/api/serializers/base.py +++ b/netbox/netbox/api/serializers/base.py @@ -76,6 +76,12 @@ class ValidatedModelSerializer(BaseModelSerializer): Extends the built-in ModelSerializer to enforce calling full_clean() on a copy of the associated instance during validation. (DRF does not do this by default; see https://github.com/encode/django-rest-framework/issues/3144) """ + + # Bypass DRF's built-in validation of unique constraints due to DRF bug #9410. Rely instead + # on our own custom model validation (below). + def get_unique_together_constraints(self, model): + return [] + def validate(self, data): # Skip validation if we're being used to represent a nested object