mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 13:17:50 +02:00
Extend the bookshelf implementation
This commit is contained in:
26
ram/bookshelf/serializers.py
Normal file
26
ram/bookshelf/serializers.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from rest_framework import serializers
|
||||
from bookshelf.models import Book, Author, Publisher
|
||||
from metadata.serializers import TagSerializer
|
||||
|
||||
|
||||
class AuthorSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Author
|
||||
fields = "__all__"
|
||||
|
||||
|
||||
class PublisherSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Publisher
|
||||
fields = "__all__"
|
||||
|
||||
|
||||
class BookSerializer(serializers.ModelSerializer):
|
||||
authors = AuthorSerializer(many=True)
|
||||
publisher = PublisherSerializer()
|
||||
tags = TagSerializer(many=True)
|
||||
|
||||
class Meta:
|
||||
model = Book
|
||||
fields = "__all__"
|
||||
read_only_fields = ("creation_time", "updated_time")
|
Reference in New Issue
Block a user