serializers.py 668 Bytes
Newer Older
Aymeric Barantal's avatar
Aymeric Barantal committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from picampaign.campaign.models import Campaign, CampaignContact, Contact
from rest_framework import serializers


class ContactSerializer(serializers.ModelSerializer):

    class Meta:
        model = Contact
        fields = ('id', 'first_name', 'last_name', 'phone')


class CampaignSerializer(serializers.HyperlinkedModelSerializer):

    class Meta:
        model = Campaign
        fields = ('id', 'title', 'description', 'start_date', 'end_date')


class CampaignContactSerializer(serializers.HyperlinkedModelSerializer):

    contact = ContactSerializer(many=False)

    class Meta:
        model = CampaignContact
        fields = ('id', 'weight', 'contact')