[Django]-Django Rest Framework: make a field not required in modelviewset create

5👍

You can make the field not required by specifying that in the ModelSerializer:

class MyModelSerializer(ModelSerializer):
    created_time = serializer.DateTimeField(required=False)

    class Meta:
        model = MyModel
        fields = ['name', 'created_time']

Leave a comment