def follow_user(request, user_id): follower = get_profile(request.user, save=True) user_to_follow = get_object_or_404(User, pk=user_id) profile_to_follow = get_profile(user_to_follow, save=True) follower.followed.add(profile_to_follow) messages.add_message(request, messages.SUCCESS, "You have followed this user.") return redirect('show_user', user_to_follow.id)
def edit_profile(request): profile = get_profile(request.user) if request.method == "GET": profile_form = ProfileForm(instance=profile) elif request.method == "POST": profile_form = ProfileForm(instance=profile, data=request.POST) if profile_form.is_valid(): profile_form.save() product_data = get_prod_data(request) service_data = get_all_service_data(request) return render(request, "edit_profile.html", {"form": profile_form, 'data1': product_data, 'data2': service_data})
def edit_profile(request): profile = get_profile(request.user) if request.method == "GET": profile_form = ProfileForm(instance=profile) elif request.method == "POST": profile_form = ProfileForm(instance=profile, data=request.POST) if profile_form.is_valid(): profile_form.save() product_data = get_prod_data(request) service_data = get_all_service_data(request) return render(request, "edit_profile.html", { "form": profile_form, 'data1': product_data, 'data2': service_data })