# coding=utf-8

from rest_framework import serializers
from .models import Notices


class NoticesSerializer(serializers.ModelSerializer):
    create_user_text = serializers.CharField(source='create_user.name', read_only=True)
    class Meta:
        model = Notices
        fields = '__all__'

    def create(self, validated_data):
        validated_data['create_user'] = self.context['request'].user
        instance = super(NoticesSerializer, self).create(validated_data)
        return instance
