from rest_framework import serializers

from . import models


class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = models.User
        exclude = ('groups', 'user_permissions')
        extra_kwargs = {
            'password': {'write_only': True, 'required': False}
        }


class LoginSerializer(serializers.Serializer):
    username = serializers.CharField(label='用户名', max_length=150)
    password = serializers.CharField(label='密码', max_length=128)
