2017-05-29 00:01:56 +01:00
|
|
|
from asyncorm.serializers import ModelSerializer, SerializerMethod
|
2017-03-27 22:47:35 +01:00
|
|
|
from library.models import Book
|
|
|
|
|
|
|
|
|
|
|
|
class BookSerializer(ModelSerializer):
|
|
|
|
book_type = SerializerMethod()
|
|
|
|
|
|
|
|
def get_book_type(self, instance):
|
|
|
|
return instance.book_type_display()
|
|
|
|
|
|
|
|
class Meta():
|
|
|
|
model = Book
|
|
|
|
fields = [
|
|
|
|
'id', 'name', 'synopsis', 'book_type', 'pages', 'date_created'
|
|
|
|
]
|