@login_required
def profile_settings(request):
    user = request.user

    has_skills = Skill.objects.count() > 0
    has_roles = Role.objects.count() > 0

    SkillFormSet = formset_factory(SkillForm, formset=BaseSkillFormSet)

    user_skills = UserSkill.objects.filter(user=user).order_by('skill__name')
    skill_data = [{'skill': s.skill, 'proficiency': s.proficiency}
                  for s in user_skills]

    LinkFormSet = formset_factory(LinkForm, formset=BaseLinkFormSet)

    user_links = UserLink.objects.filter(user=user).order_by('anchor')
    link_data = [{'anchor': l.anchor, 'url': l.url}
                 for l in user_links]

    if request.method == 'POST':
        form = ProfileForm(request.POST, user=user)
        skill_formset = SkillFormSet(request.POST, prefix='skill')
        link_formset = LinkFormSet(request.POST, prefix='link')

        forms = [form, link_formset]

        if has_skills:
            forms.append(skill_formset)

        if all([f.is_valid() for f in forms]):
            # Save user info
            user.full_name = form.cleaned_data['full_name']
            user.bio = form.cleaned_data['bio']
            user.roles = form.cleaned_data['roles']
            user.save()

            if has_skills:
                save_skills(request, user, skill_formset)

            save_links(request, user, link_formset)

            user_links = UserLink.objects.filter(user=user)
            match_link_to_brand(user_links)

            site = get_current_site(request)
            messages.success(request, _(
                'Your {} profile has been updated.'.format(site.name)))

    else:
        form = ProfileForm(user=user)
        skill_formset = SkillFormSet(initial=skill_data, prefix='skill')
        link_formset = LinkFormSet(initial=link_data, prefix='link')

    context = {
        'form': form,
        'skill_formset': skill_formset,
        'link_formset': link_formset,
        'has_skills': has_skills,
        'has_roles': has_roles,
    }

    return render(request, 'accounts/profile_settings.html', context)
Allows a user to update their own profile.
dataset/ETHPy150Open nlhkabu/connect/connect/accounts/views.py/profile_settings