We want to set all the required fields if admin is set, and we want
        to use the password hashing method if password is set.

def update(self, instance, validated_data):
        '''We want to set all the required fields if admin is set, and we want
        to use the password hashing method if password is set.'''
        admin = validated_data.pop('is_superuser', None)
        password = validated_data.pop('password', None)
        if validated_data.get('email') is not None:
            validated_data['username'] = validated_data['email']

        for attr, value in validated_data.items():
            setattr(instance, attr, value)
        if admin is not None:
            instance.is_staff = admin
            instance.is_superuser = admin
        if password is not None:
            instance.set_password(password)

        instance.save()
        return instance