Is there a way to remap the names of Django Rest Framewok SerializerFields to strings that contain spaces?
I have the following sort of code:
models.py:
class Author(models.Model):
author_name = models.CharField()
serialisers.py:
class AuthorSerializer(serializers.ModelSerializer):
class Meta:
model = Author
fields = ["author_name"]
This will return JSON like:
{ "author_name": "William Shakespeare" }
But I want it to return JSON like:
{ "The Author": "William Shakespare" }
I know that I can use a different name for a serializer field using the source kwarg, but that still requires a valid python name. I'm specifically wondering if I can use a name with spaces in it.
Thanks.