Spaces:
Configuration error
Configuration error
File size: 1,163 Bytes
52a3fd6 99122b8 52a3fd6 99122b8 52a3fd6 99122b8 52a3fd6 99122b8 52a3fd6 99122b8 |
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 26 27 28 29 30 31 32 33 |
from rest_framework import serializers
from .models import User
class UserRegistrationSerializer(serializers.ModelSerializer):
password = serializers.CharField(write_only=True)
class Meta:
model = User
fields = ['email', 'password', 'first_name', 'last_name', 'mobile', 'address', 'city', 'state', 'country', 'zip_code', 'role']
extra_kwargs = {
'first_name': {'required': False},
'last_name': {'required': False},
'mobile': {'required': False},
'address': {'required': False},
'city': {'required': False},
'state': {'required': False},
'country': {'required': False},
'zip_code': {'required': False},
'role': {'required': False},
}
def create(self, validated_data):
user = User.objects.create_user(**validated_data)
return user
class ForgotPasswordSerializer(serializers.Serializer):
email = serializers.EmailField()
class ResetPasswordSerializer(serializers.Serializer):
token = serializers.CharField()
uid = serializers.CharField()
new_password = serializers.CharField() |