Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Last active August 25, 2020 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save velotiotech/54e716e3c1fc1afb6e688291c89dafae to your computer and use it in GitHub Desktop.
Save velotiotech/54e716e3c1fc1afb6e688291c89dafae to your computer and use it in GitHub Desktop.
class BookSerializer(serializers.ModelSerializer):
author = AuthorSerializer()
book_display_name= serializers.SerializerMethodField(source="get_book_display_name")
def get_book_display_name(self, book):
return book.name.upper()
class Meta:
model = Book
fields = "__all__"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment