@login_required
def update_profile(request, username):
    user = User.objects.get(username=username)
    profile = Profile.filter_profile_by_id(user.id)
    form = UpdateUserProfileForm(instance=profile)
    if (request.method == 'POST'):
        form = UpdateUserProfileForm(request.POST, request.FILES, instance=profile)
        if form.is_valid():
            profile = form.save(commit=False)
            profile.save()
            return redirect('main:profile', username=username)
    ctx = {'form': form}
    return render(request, 'profile/update_profile.html', ctx)
@login_required
def update_profile(request, username):
    user = User.objects.get(username=username)
    profile = Profile.filter_profile_by_id(user.id)
    form = UpdateUserProfileForm(instance=profile)
    if (request.method == 'POST'):
        form = UpdateUserProfileForm(request.POST, request.FILES, instance=profile)
        if form.is_valid():
            profile = form.save(commit=False)
            profile.save()
            return redirect('main:profile', username=username)
    ctx = {'form': form}
    return render(request, 'profile/update_profile.html', ctx)