You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

75 lines
1.4 KiB

from django.contrib.contenttypes.models import ContentType
from rest_framework.serializers import ModelSerializer
from .models import Location
class NestedLocationSerializer(ModelSerializer):
class Meta:
model = Location
fields = (
'children',
'id',
'level',
'lft',
'name',
'parent',
'rght',
'tree_id',
'type',
)
class NestedLocationSerializerFlat(ModelSerializer):
class Meta:
model = Location
fields = (
'id',
)
class LocationSerializer(ModelSerializer):
children = NestedLocationSerializer(many=True)
parent = NestedLocationSerializer()
class Meta:
model = Location
fields = (
'children',
'id',
'level',
'lft',
'name',
'parent',
'rght',
'tree_id',
'type',
)
class LocationSerializerFlat(ModelSerializer):
children = NestedLocationSerializerFlat(many=True)
parent = NestedLocationSerializerFlat()
class Meta:
model = Location
fields = (
'id',
'name',
'children',
'parent')
class ContentTypeSerializer(ModelSerializer):
class Meta:
model = ContentType
fields = (
'app_label',
'id',
'model',
)