# Key error in sign up serializer

**URL:** <https://forum.djangoproject.com/t/key-error-in-sign-up-serializer/11991>\
**Category:** Using Django\
**Created:** [February 6, 2022, 12:19am UTC](https://forum.djangoproject.com/t/key-error-in-sign-up-serializer/11991 "2022-02-06T00:19:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![LMarshallAfzal](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/lmarshallafzal/32/7343_2.png) [@LMarshallAfzal](https://forum.djangoproject.com/u/LMarshallAfzal)\
**Post date:** [February 6, 2022, 12:19am UTC](https://forum.djangoproject.com/t/key-error-in-sign-up-serializer/11991/1 "2022-02-06T00:19:19Z")

</div>

Here is the serilializer causing the issue. There is a problem with the create function where the validated data cannot process `first_name` because it is not validated at the top, but I don’t want it to have a unique validation, so what do I do?

```auto
class SignUpSerializer(serializers.Serializer):
    username = serializers.CharField(
        required = True,
        validators = [UniqueValidator(queryset=User.objects.all())]
    )
    email = serializers.CharField(
        required = True,
        validators = [UniqueValidator(queryset=User.objects.all())]
    )
    password = serializers.CharField(write_only = True,required = True,validators=[validate_password])
    password_confirmation = serializers.CharField(write_only = True,required = True)

    class Meta:
        model = User
        fields = ['username', 'first_name', 'last_name', 'email', 'bio', 'preferences', 'password', 'password_confirmation']
        extra_kwargs = {
            'first_name': {'required': True},
            'last_name': {'required': True},
            'preferences': {'required': True}
        }
    def validate(self,data):
        if data['password'] != data['password_confirmation']:
            raise serializers.ValidationError({"password": "Passwords don't match."})
        return data
    
    def create(self,validated_data):
        user = User.objects.create(
            username = validated_data['username'],
            first_name = validated_data['first_name'],
            last_name = validated_data['last_name'],
            email = validated_data['email'],
            bio = validated_data['bio'],
            preferences = validated_data['preferences']
        )

        user.set_password(validated_data['password'])
        user.save()

        return user

```
