index.community/apiv1/serializers.py

24 lines
649 B
Python
Raw Normal View History

2018-08-26 00:32:55 +00:00
from rest_framework import serializers
2018-08-26 22:12:24 +00:00
from scraper.models import Instance, InstanceStats
2018-08-26 00:32:55 +00:00
2018-08-26 22:12:24 +00:00
class InstanceStatsSerializer(serializers.ModelSerializer):
class Meta:
model = InstanceStats
exclude = ('id', 'instance', 'status')
class InstanceListSerializer(serializers.ModelSerializer):
class Meta:
model = Instance
fields = ('name', )
class InstanceDetailSerializer(serializers.ModelSerializer):
peers = InstanceListSerializer(many=True, read_only=True)
stats = InstanceStatsSerializer(many=True, read_only=True)
2018-08-26 00:32:55 +00:00
class Meta:
model = Instance
2018-08-26 22:12:24 +00:00
fields = ('name', 'stats', 'peers')