serializers.py 767 B

123456789101112131415161718192021
  1. from __future__ import print_function, unicode_literals
  2. from rest_framework.serializers import ModelSerializer
  3. from rest_framework_bulk.serializers import BulkListSerializer, BulkSerializerMixin
  4. from .models import SimpleModel, UniqueTogetherModel
  5. class SimpleSerializer(BulkSerializerMixin, # only required in DRF3
  6. ModelSerializer):
  7. class Meta(object):
  8. model = SimpleModel
  9. # only required in DRF3
  10. list_serializer_class = BulkListSerializer
  11. class UniqueTogetherSerializer(BulkSerializerMixin, # only required in DRF3
  12. ModelSerializer):
  13. class Meta(object):
  14. model = UniqueTogetherModel
  15. # only required in DRF3
  16. list_serializer_class = BulkListSerializer