redirect errot – NoReverseMatch: Reverse for ‘edit’ with keyword arguments ‘{‘title’: ‘Python’}’ not found

I'm working on an app that allows the user to create, show and edit an entry. right now i'm working on the editing function. what i'm trying to do is have an edit button (that's actually a form that sends data via hidden inputs) that sends the title of the entry to a view called trans whose sole purpose is redirect to the edit view, the reason i did this is so that when i'm working on the edit view, i can simplify the process where if the request method is GET it shows the page with the form where the user can edit the entry and if it's post the edit view can receive the changes and save them without worrying about the redirecting from the entry's page.

The problem lies in the fact that everytime i click the edit button i get the error:

NoReverseMatch at /wiki/trans
Reverse for 'edit' with keyword arguments '{'title': 'Python'}' not found.

I have checked over and over for any misspellings or issues in or any problems with the naming but i just can't find the bug. and it's frustrating because i thought that this would be the easiest part of the project.

Below is the relevant code. i would be extremely grateful for anyone who points out what i'm doing wrong. Thank you in Advance.


<div id="edit">
    <form action="{% url 'wiki:trans' %}" method="POST">
        {% csrf_token %}
        <input type=hidden value={{title}} name="title">
        <input type=submit value="Edit">

class EntryForm(forms.Form):
    title = forms.CharField(label="Title")
    content = forms.CharField(widget=forms.Textarea)

def trans(request):
    title = request.POST.get("title")
    return redirect("wiki:edit", title=title)

def edit(request, title):
    if request.method == "GET":
        entry = util.get_entry(title)

        return render(request, "encyclopedia/edit.html", {
            "form": EntryForm({
                "content": entry,
                "title": title
        form = EntryForm(request.POST)

        if form.is_valid():
            title = form.cleaned_data["title"]
            content = form.cleaned_data["content"]

        util.save_entry(title, content)
        return redirect("wiki:title", title=title)

app_name = "wiki"
urlpatterns = [
    path("", views.index, name="index"),
    path("search",, name="search"),
    path("new",, name="new"),
    path("trans", views.trans, name="trans"),
    path("edit", views.edit, name="edit"),
    path("random", views.rand, name="random"),
    path("<str:title>", views.title, name="title")

Read more here:

Content Attribution

This content was originally published by sunflower.saturn at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: