Переглянути джерело

Fixed compatability with Django REST Framework v3.9.0

Jeremy Stretch 7 роки тому
батько
коміт
bb5c0989f3
2 змінених файлів з 8 додано та 1 видалено
  1. 7 0
      netbox/utilities/api.py
  2. 1 1
      requirements.txt

+ 7 - 0
netbox/utilities/api.py

@@ -165,6 +165,13 @@ class WritableNestedSerializer(ModelSerializer):
     """
     Returns a nested representation of an object on read, but accepts only a primary key on write.
     """
+    def run_validators(self, value):
+        # DRF v3.8.2: Skip running validators on the data, since we only accept an integer PK instead of a dict. For
+        # more context, see:
+        #  https://github.com/encode/django-rest-framework/pull/5922/commits/2227bc47f8b287b66775948ffb60b2d9378ac84f
+        #  https://github.com/encode/django-rest-framework/issues/6053
+        return
+
     def to_internal_value(self, data):
         if data is None:
             return None

+ 1 - 1
requirements.txt

@@ -7,7 +7,7 @@ django-tables2==1.21.2
 django-taggit==0.22.2
 django-taggit-serializer==0.1.7
 django-timezone-field==2.1
-djangorestframework==3.8.1
+djangorestframework==3.8.2
 drf-yasg[validation]==1.9.2
 graphviz==0.8.4
 Markdown==2.6.11