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()