UPDATE: I'm trying to use HttpResponseRedirect() to guide the user back to the entry page but it's not working for me somehow with this syntax: return HttpResponseRedirect((entry_page(request, title))
I'm working through a Wiki project for CS50's web course and I'm having an issue with my edit entry implementation. I'm able to edit an entry and it saves properly but for some reason, redirecting the user to the newly edited entry is only showing an empty entry page like this:
here's my views. py:
def edit(request, title):
content = util.get_entry(title)
if request.method == "GET":
return render(request, "encyclopedia/edit.html", {
"title": title,
"content": content
})
elif request.method == "POST":
title = request.POST.get("title")
content = request.POST.get("content")
util.save_entry(title, content)
html = md_converter(util.get_entry(title))
return render(request, "encyclopedia/entry.html", {
"title": title,
"content": html
})
else:
return render(request, "encyclopedia/edit.html", {
"title": title,
})
and my urls.py:
from . import views
app_name = "encyclopedia"
urlpatterns = [
path("", views.index, name="index"),
path("wiki/<str:entry>", views.entry_page, name="entry"),
path("wiki/edit/<str:title>", views.edit, name="edit"),
path("search", views.search, name="search"),
path("random", views.random_page, name="random"),
path("create_landing",views.create_landing_page, name="create_landing"),
path("create_entry",views.create_entry, name="create_entry")
]
Is there something wrong with my redirect? When I revisit the entry page, the page shows the edits I made
Thanks so much for reviewing.