# coding=utf-8

from rest_framework import serializers
from apps.WechatTp.models import WechatTp


class WechatTpSerializer(serializers.ModelSerializer):

    class Meta:
        model = WechatTp
        fields = '__all__'

    def create(self, validated_data):
        instance = WechatTp.objects.filter().first()
        if instance:
            instance = super(WechatTpSerializer, self).update(instance, validated_data)
        else:
            instance = super(WechatTpSerializer, self).create(validated_data)
        return instance
