serializers.py 631 Bytes
Newer Older
1 2 3 4
from __future__ import absolute_import

from rest_framework.serializers import ModelSerializer

5
from pushnotifications.models import Device, Category
6 7 8 9 10 11


class DeviceSerializer(ModelSerializer):
    class Meta:
        model = Device

12 13 14 15 16 17 18 19
        fields = (
            'pk',
            'registration_id',
            'active',
            'date_created',
            'type',
            'receive_category'
        )
20 21 22
        read_only_fields = ('date_created',)

        extra_kwargs = {'active': {'default': True}}
23 24 25 26 27 28 29


class CategorySerializer(ModelSerializer):
    class Meta:
        model = Category

        fields = ('key', 'name')