Marble/server/user/serializers.py
2024-10-05 19:53:31 +04:00

27 lines
836 B
Python

from dj_rest_auth.registration.serializers import RegisterSerializer
from rest_framework import serializers
from .models import User
class CustomRegisterSerializer(RegisterSerializer):
email = serializers.EmailField(required=True)
password1 = serializers.CharField(write_only=True)
password2 = serializers.CharField(write_only=True)
def get_cleaned_data(self):
super(CustomRegisterSerializer, self).get_cleaned_data()
return {
'email': self.validated_data.get('email', ''),
'password1': self.validated_data.get('password1', ''),
'password2': self.validated_data.get('password2', ''),
}
class CustomUserDetailsSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = ('email',)
read_only_fields = ('email',)