I would like to let the user know that their information has been updated once they have filled out the form and clicked the "update" button. Right now everything works but after they click the "update" button they get redirected to their profile to see the new information. I'd like to also have a little note that says something like "Your profile has been updated" on that HTML template. I know that I can passthrough arguments using the render method, but I'm wondering how/if it's possible to do so with redirect.
Here's my edit_profile function from views.py:
@login_required
def edit_profile(request):
if request.method == 'POST':
form = EditProfileForm(request.POST, instance=request.user)
if form.is_valid():
form.save()
return redirect(reverse("view_profile"))
else:
form = EditProfileForm(instance=request.user)
args = {'form': form}
return render(request, 'accounts/edit_profile.html', args)
Is there any way to pass through a variable that contains a message that I can display in my HTML template like this using the redirect method?
<!-- if profile is updated succesfully -->
{{ success }}
Thanks