I need to redirect the user to a new page that says, "Thank you for contacting us" after submitting a form with Django.
I have tried using HttpResponseRedirect, reverse but I don't know how to implement it to all of the necessary files of my project.
from django.shortcuts import render
from .forms import ContactForm
# Create your views here.
def contact(request):
template = "contact.html"
if request.method == "POST":
form = ContactForm(request.POST)
if form.is_valid():
form.save()
else:
form = ContactForm()
context = {
"form": form,
}
return render(request, template, context)
When I click submit, it sends the data to the Django database so the form does work but the user does not know that because after they click submit it doesn't redirect to a thank you page.