Пример #1
0
 def validate_pk_based_nested(self, data):
     queryset = self.Meta.model.objects.all()
     validator = PrimaryKeyRelatedField(**self.validation_kwargs,
                                        queryset=queryset,
                                        many=False)
     obj = validator.run_validation(data)
     return obj
Пример #2
0
 def validate_pk_list(self, pks):
     ListField().run_validation(pks)
     queryset = self.child.Meta.model.objects.all()
     validator = PrimaryKeyRelatedField(
         queryset=queryset,
         many=True
     )
     return validator.run_validation(pks)
Пример #3
0
 def run_pk_validation(self, pk):
     queryset = self.Meta.model.objects.all()
     validator = PrimaryKeyRelatedField(
         **self.validation_kwargs,
         queryset=queryset,
         many=False
     )
     # If valid return object instead of pk
     return validator.run_validation(pk)