Skip to content

Commit

Permalink
Fixes #17810: Disable DRF's native unique constraint checks
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Dec 5, 2024
1 parent 327ad8c commit 8c9bb73
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions netbox/netbox/api/serializers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8c9bb73

Please sign in to comment.