我想使用Django restframework执行批量更新, https://github.com/miki725/django-rest-framework-bulk,我尝试使用此程序包失败。任何人都知道如何进行批量更新
模型类
class Member(models.Model):
name = models.CharField(max_length=50)
class Meta:
"""Meta definition for Member."""
verbose_name = 'Member'
verbose_name_plural = 'Members'
def __str__(self):
return self.name
序列化器类
from rest_framework_bulk import BulkListSerializer, BulkSerializerMixin
class MemberBulkSerializer(BulkSerializerMixin, serializers.ModelSerializer):
class Meta:
model = Member
fields = '__all__'
list_serializer_class = BulkListSerializer
查看
class MemberBulkView(ListBulkCreateUpdateDestroyAPIView):
queryset = Member.objects.all()
serializer_class = MemberBulkSerializer
网址
urlpatterns = [
path('bulk/', MemberBulkView)
]