25 lines
627 B
Python
25 lines
627 B
Python
from rest_framework import serializers
|
|
|
|
from apps.books.models import Book
|
|
from apps.shelves.serializers import ShelfSerializer
|
|
from apps.shelves.models import Shelf
|
|
|
|
class BookSerializer(serializers.ModelSerializer):
|
|
#shelf = ShelfSerializer(read_only=True)
|
|
#shelf_id = serializers.PrimaryKeyRelatedField(
|
|
#queryset=Shelf.objects.all(),
|
|
#source="shelf",
|
|
#write_only=True
|
|
#)
|
|
|
|
|
|
class Meta:
|
|
model = Book
|
|
fields = [
|
|
"id",
|
|
"name",
|
|
"isbn",
|
|
#"shelf",
|
|
#"shelf_id"
|
|
]
|
|
read_only_fields = ["id"] |