encyclopedia/views.py
def edit(request, entry):

    """ Function to edit the requested page """

    if request.method == "GET":
        title = entry
        textarea = util.get_entry(title)

        # Pre-populate the form with existing content
        form = CreateNewPage({"title": title, "textarea": textarea})

        return render(request, "encyclopedia/edit.html", {
            "form": form,
            "title":title
        })

    if request.method == "POST":
        
        # after editing, save the contents
        form = CreateNewPage(request.POST)

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

            util.save_entry(title, textarea)
            return redirect("entry", title)
 Function to edit the requested page 
Function to edit the requested page
Function to edit the requested page
def edit(request, entry):
    if request.method == "GET":
        title = entry
        textarea = util.get_entry(title)
        form = CreateNewPage({"title": title, "textarea": textarea})
        return render(request, "encyclopedia/edit.html", {
            "form": form,
            "title":title
        })
    if request.method == "POST":
        form = CreateNewPage(request.POST)
        if form.is_valid():
            title = form.cleaned_data["title"]
            textarea = form.cleaned_data["textarea"]
            util.save_entry(title, textarea)
            return redirect("entry", title)
def edit ( request , entry ) : if request . method == "GET" : title = entry textarea = util . get_entry ( title ) form = CreateNewPage ( { "title" : title , "textarea" : textarea } ) return render ( request , "encyclopedia/edit.html" , { "form" : form , "title" : title } ) if request . method == "POST" : form = CreateNewPage ( request . POST ) if form . is_valid ( ) : title = form . cleaned_data [ "title" ] textarea = form . cleaned_data [ "textarea" ] util . save_entry ( title , textarea ) return redirect ( "entry" , title )
Function to edit the requested page
Function to edit the requested page
""" Function to edit the requested page """ # Pre-populate the form with existing content # after editing, save the contents
request
entry