example-of-crud-in-django-w.../app/library/serializers.py

16 lines
320 B
Python
Raw Permalink Normal View History

2021-07-14 16:19:03 +02:00
# app/Library/serializers.py
2021-07-09 19:09:31 +02:00
from rest_framework import serializers
2021-07-14 16:19:03 +02:00
from .models import Book
2021-07-09 19:09:31 +02:00
2021-07-14 16:19:03 +02:00
class BookSerializer(serializers.ModelSerializer):
2021-07-09 19:09:31 +02:00
class Meta:
2021-07-14 16:19:03 +02:00
model = Book
2021-07-09 19:09:31 +02:00
fields = "__all__"
read_only_fields = (
"id",
2021-07-13 18:18:18 +02:00
"created_at",
"updated_at",
2021-07-09 19:09:31 +02:00
)