views.py 722 B

12345678910111213141516171819202122232425
  1. from __future__ import unicode_literals, print_function
  2. from rest_framework_bulk import generics
  3. from .models import SimpleModel
  4. from .serializers import SimpleSerializer
  5. class SimpleMixin(object):
  6. model = SimpleModel
  7. queryset = SimpleModel.objects.all()
  8. serializer_class = SimpleSerializer
  9. class SimpleBulkAPIView(SimpleMixin, generics.ListBulkCreateUpdateDestroyAPIView):
  10. pass
  11. class FilteredBulkAPIView(SimpleMixin, generics.ListBulkCreateUpdateDestroyAPIView):
  12. def filter_queryset(self, queryset):
  13. return queryset.filter(number__gt=5)
  14. class SimpleViewSet(SimpleMixin, generics.BulkModelViewSet):
  15. def filter_queryset(self, queryset):
  16. return queryset.filter(number__gt=5)