Skip to content

Instantly share code, notes, and snippets.

@llloo
llloo / serializers.py
Created June 22, 2022 03:10 — forked from abirafdirp/serializers.py
Serialize tree model structure in DRF
from rest_framework import serializers
from .models import ClonedTopic, Topic, Note, ExternalDocument
# The reason Create and List is separated is that,
# if we specify depth, then somehow some of the fields are disabled/not,
# available when we do a POST, so we can't essentialy create an object!
# This issue is reproduceable you can test it for yourself,
# but as for the reason why, I am not investigate it yet.
# A separate serializer without depth is needed for CreateView.