[Fixed]-Django REST framework : IntegrityError at serializers_user_data.owner_id may not be NULL

1👍

I used perform_create method instead of pre_save

def perform_create(self, serializer):
    serializer.save(owner=self.request.user)
👤Naresh

0👍

Set ipdb in your code

    def pre_save(self, obj):
    import ipdb; ipdb.set_trace()
    obj.owner = self.request.user
    print obj.owner

And check the request.user attribute to understand the error.

Leave a comment