'Update the profile, including nested fields.'

def update(self, instance, validated_data):

    language_proficiencies = validated_data.pop('language_proficiencies', None)
    update_fields = (set(self.get_writeable_fields()) - set(['language_proficiencies']))
    for field_name in update_fields:
        default = getattr(instance, field_name)
        field_value = validated_data.get(field_name, default)
        setattr(instance, field_name, field_value)
    instance.save()
    if (language_proficiencies is not None):
        instance.language_proficiencies.all().delete()
        instance.language_proficiencies.bulk_create([LanguageProficiency(user_profile=instance, code=language['code']) for language in language_proficiencies])
    return instance
