Hello,
Take this ModelSerializer for example:
class MyModel(models.Model):
my_field = models.DateTimeField(null=True, blank=True)
class MyModelSerializer(serializers.ModelSerializer):
class Meta:
model = MyModel
fields = ["my_field"]
read_only_fields = ["my_field"]
If you generate this serializer schema you will notice that the null=True was ignored by the generated schema
>>> inspector = AutoSchema()
>>> schema = inspector.map_serializer(MyModelSerializer())
>>> schema['properties']['my_field']
{'type': 'string', 'format': 'date-time', 'readOnly': True}
Removing the from the read_only_fields fixes the problem and the schema goes back to:
{'type': 'string', 'format': 'date-time', 'nullable': True}