[Django]-JSONField doesn't allow null in Django 3.1

5👍

Set allow_null=True in your serializer:

class MyModelSerializer(serializers.ModelSerializer):   
    my_data = serializers.JSONField(allow_null=True)

In DRF allow_null is False by default, even if your model is configured to accept null.

👤GProst

Leave a comment