mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 20:40:14 +03:00
updated patch with additional checks where request method may not be populated
This commit is contained in:
parent
4b62a8e8bd
commit
f98d487931
|
@ -592,7 +592,8 @@ class ModelSerializer(Serializer):
|
|||
# Note that we make sure to check `unique_together` both on the
|
||||
# base model class, but also on any parent classes.
|
||||
for parent_class in [model_class] + list(model_class._meta.parents.keys()):
|
||||
if self.context.get('request').method != 'PATCH':
|
||||
http_method = getattr(self.context.get('request'), 'method', None)
|
||||
if http_method and http_method != 'PATCH':
|
||||
for unique_together in parent_class._meta.unique_together:
|
||||
if field_names.issuperset(set(unique_together)):
|
||||
validator = UniqueTogetherValidator(
|
||||
|
|
Loading…
Reference in New Issue
Block a user