0

I am using djangorestframework-bulk to perform bulk update have followed documentation DRF-Bulk but for me update wasnt working..

it says,

File "/webapps/env_apibot/local/lib/python2.7/site-packages/rest_framework_bulk/drf3/serializers.py", line 43, in <dictcomp>
    for i in all_validated_data
KeyError: 'my_pk'

my configuration was,

views.py

class MymodelBulkViewSet(BulkModelViewSet):
    model = Mymodel
    queryset = Mymodel.objects.all()
    serializer_class = MymodelBulkSerializer

serializers.py

class MymodelBulkSerializer(BulkSerializerMixin):
    class Meta:
        model = Mymodel
        list_serializer_class = BulkListSerializer
        update_lookup_field = 'my_pk'

models.py

class BillingItem(models.Model):
    my_pk = models.AutoField(max_length=11, primary_key=True)

class Meta:
    managed = False

but it raise 400 error and it says, key error my_pk not found..

drf version 3.3.2

django 1.8.9

Mohideen bin Mohammed
  • 18,813
  • 10
  • 112
  • 118

1 Answers1

0

I have Resolved this with long research finally i found myself..

i tried to override BulkListSerializer now its works fine without i made any changes in it.. i went through finally i found BulkSerializerMixin, BulkListSerializer getting repeated and it tried to import it from,

from rest_framework_bulk import BulkSerializerMixin, BulkListSerializer

but actually it should be from,

from rest_framework_bulk.drf3.serializers import BulkSerializerMixin, BulkListSerializer
Mohideen bin Mohammed
  • 18,813
  • 10
  • 112
  • 118