spejstore-new/storage/serializers.py

17 lines
555 B
Python
Raw Normal View History

2017-04-28 12:14:27 +00:00
from storage.models import Item, Label
2017-03-06 15:50:55 +00:00
from rest_framework import serializers
from rest_framework_hstore.serializers import HStoreSerializer
class ItemSerializer(HStoreSerializer):
class Meta:
model = Item
fields = ('uuid', 'name', 'description', 'props', 'state', 'parent')
2017-04-28 12:14:27 +00:00
class LabelSerializer(serializers.ModelSerializer):
item = ItemSerializer()
2017-09-05 23:23:04 +00:00
item_id = serializers.PrimaryKeyRelatedField(queryset=Item.objects, source='item')
2017-04-28 12:14:27 +00:00
class Meta:
model = Label
2017-09-05 23:23:04 +00:00
fields = ('id', 'item', 'item_id', 'style')