{"id":5875,"date":"2022-11-28T04:39:02","date_gmt":"2022-11-28T04:39:02","guid":{"rendered":"https:\/\/www.pythontutorial.net\/?page_id=5875"},"modified":"2023-08-17T09:25:20","modified_gmt":"2023-08-17T09:25:20","slug":"django-edit-form","status":"publish","type":"page","link":"https:\/\/www.pythontutorial.net\/django-tutorial\/django-edit-form\/","title":{"rendered":"Django Edit Form"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you&#8217;ll learn how to create a Django edit form to update a post and save the changes into the database.<\/p>\n\n\n\n<p class=\"note\">This tutorial begins where&nbsp;creating <a href=\"https:\/\/www.pythontutorial.net\/django-tutorial\/django-flash-messages\/\">Django flash messages<\/a> tutorial&nbsp;left off.<\/p>\n\n\n\n<p>We&#8217;ll create a Django Edit Form that updates a blog post and saves the changes into the database.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='create-an-url-pattern'>Create an URL pattern <a href=\"#create-an-url-pattern\" class=\"anchor\" id=\"create-an-url-pattern\" title=\"Anchor for Create an URL pattern\">#<\/a><\/h2>\n\n\n\n<p>First, create a URL pattern for editing a post:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python shcb-code-table\"><span class='shcb-loc'><span><span class=\"hljs-keyword\">from<\/span> django.urls <span class=\"hljs-keyword\">import<\/span> path\n<\/span><\/span><span class='shcb-loc'><span><span class=\"hljs-keyword\">from<\/span> . <span class=\"hljs-keyword\">import<\/span> views\n<\/span><\/span><span class='shcb-loc'><span>\n<\/span><\/span><span class='shcb-loc'><span>urlpatterns = &#91;\n<\/span><\/span><span class='shcb-loc'><span>    path(<span class=\"hljs-string\">''<\/span>, views.home, name=<span class=\"hljs-string\">'posts'<\/span>),\n<\/span><\/span><span class='shcb-loc'><span>    path(<span class=\"hljs-string\">'post\/create'<\/span>, views.create_post, name=<span class=\"hljs-string\">'post-create'<\/span>),\n<\/span><\/span><mark class='shcb-loc'><span>    path(<span class=\"hljs-string\">'post\/edit\/&lt;int:id&gt;\/'<\/span>, views.edit_post, name=<span class=\"hljs-string\">'post-edit'<\/span>),\n<\/span><\/mark><span class='shcb-loc'><span>    path(<span class=\"hljs-string\">'about\/'<\/span>, views.about, name=<span class=\"hljs-string\">'about'<\/span>),\n<\/span><\/span><span class='shcb-loc'><span>]\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The editing post URL accepts an id as an integer specified by the <code>&lt;int:id&gt;<\/code> pattern. For example, if you edit the post with id 1, the URL will be:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">http:\/\/<span class=\"hljs-number\">127.0<\/span><span class=\"hljs-number\">.0<\/span><span class=\"hljs-number\">.1<\/span>\/post\/update\/<span class=\"hljs-number\">1<\/span>\/<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Django will pass the id (1) to the second argument to the <code>edit_post()<\/code> function.<\/p>\n\n\n\n<p>If you pass a value that is not an integer to the URL like this: <\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">http:\/\/<span class=\"hljs-number\">127.0<\/span><span class=\"hljs-number\">.0<\/span><span class=\"hljs-number\">.1<\/span>\/post\/update\/abcd\/<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Django will redirect to 404 because it doesn&#8217;t match any URL in the URL patterns.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='define-a-view-function'>Define a view function <a href=\"#define-a-view-function\" class=\"anchor\" id=\"define-a-view-function\" title=\"Anchor for Define a view function\">#<\/a><\/h2>\n\n\n\n<p>Define the <code>edit_post()<\/code> function in the <code>views.py<\/code> file:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python shcb-code-table\"><mark class='shcb-loc'><span><span class=\"hljs-keyword\">from<\/span> django.shortcuts <span class=\"hljs-keyword\">import<\/span> render,redirect, get_object_or_404\n<\/span><\/mark><span class='shcb-loc'><span><span class=\"hljs-keyword\">from<\/span> django.contrib <span class=\"hljs-keyword\">import<\/span> messages\n<\/span><\/span><span class='shcb-loc'><span><span class=\"hljs-keyword\">from<\/span> .models <span class=\"hljs-keyword\">import<\/span> Post\n<\/span><\/span><span class='shcb-loc'><span><span class=\"hljs-keyword\">from<\/span> .forms <span class=\"hljs-keyword\">import<\/span> PostForm\n<\/span><\/span><span class='shcb-loc'><span>\n<\/span><\/span><span class='shcb-loc'><span>    \n<\/span><\/span><mark class='shcb-loc'><span><span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">edit_post<\/span><span class=\"hljs-params\">(request, id)<\/span>:<\/span>\n<\/span><\/mark><mark class='shcb-loc'><span>    post = get_object_or_404(Post, id=id)\n<\/span><\/mark><mark class='shcb-loc'><span>\n<\/span><\/mark><mark class='shcb-loc'><span>    <span class=\"hljs-keyword\">if<\/span> request.method == <span class=\"hljs-string\">'GET'<\/span>:\n<\/span><\/mark><mark class='shcb-loc'><span>        context = {<span class=\"hljs-string\">'form'<\/span>: PostForm(instance=post), <span class=\"hljs-string\">'id'<\/span>: id}\n<\/span><\/mark><mark class='shcb-loc'><span>        <span class=\"hljs-keyword\">return<\/span> render(request,<span class=\"hljs-string\">'blog\/post_form.html'<\/span>,context)\n<\/span><\/mark><span class='shcb-loc'><span>\n<\/span><\/span><span class='shcb-loc'><span><span class=\"hljs-comment\"># other functions<\/span>\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>How it works:<\/p>\n\n\n\n<p>First, import <code>get_object_or_404<\/code> function from the <code>django.shortcuts<\/code> module:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">from<\/span> django.shortcuts <span class=\"hljs-keyword\">import<\/span> render,redirect, get_object_or_404<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>get_object_or_404()<\/code> function gets an object by id or redirects to the 404 page if the id doesn&#8217;t exist.<\/p>\n\n\n\n<p>Second, define the <code><code>edit_post()<\/code><\/code> function that accepts an <code>HttpRequest<\/code> object (<code>request<\/code>) and an <code>id<\/code> as an integer. <\/p>\n\n\n\n<p>The <code><code>edit_post()<\/code><\/code> function does the following steps: <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Get a <code>Post<\/code> object by id or redirect to the 404 page if the id doesn&#8217;t exist.<\/li>\n\n\n\n<li>Create a <code>PostForm<\/code> object and set the <code>instance<\/code> argument to the <code>post<\/code> object.<\/li>\n\n\n\n<li>Render the <code>post_form.html<\/code> template.<\/li>\n<\/ul>\n\n\n\n<p>Third, modify the <code>post_form.html<\/code> template to change the heading of the form. Currently, it shows <code>Create Post<\/code>.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml shcb-code-table\"><span class='shcb-loc'><span>{% extends 'base.html' %}\n<\/span><\/span><span class='shcb-loc'><span>\t\n<\/span><\/span><span class='shcb-loc'><span>{% block content %}\n<\/span><\/span><span class='shcb-loc'><span>\n<\/span><\/span><mark class='shcb-loc'><span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h2<\/span>&gt;<\/span>{% if id %} Edit {% else %} New {% endif %} Post<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h2<\/span>&gt;<\/span>\n<\/span><\/mark><span class='shcb-loc'><span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">form<\/span> <span class=\"hljs-attr\">method<\/span>=<span class=\"hljs-string\">\"post\"<\/span> <span class=\"hljs-attr\">novalidate<\/span>&gt;<\/span>\n<\/span><\/span><span class='shcb-loc'><span>\t{% csrf_token %}\n<\/span><\/span><span class='shcb-loc'><span>\t{{ form.as_p }}\n<\/span><\/span><span class='shcb-loc'><span>\t<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">input<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\">\"submit\"<\/span> <span class=\"hljs-attr\">value<\/span>=<span class=\"hljs-string\">\"Save\"<\/span> \/&gt;<\/span>\n<\/span><\/span><span class='shcb-loc'><span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">form<\/span>&gt;<\/span>\n<\/span><\/span><span class='shcb-loc'><span>\n<\/span><\/span><span class='shcb-loc'><span>{% endblock content %}\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>If the <code>id<\/code> (post id) is available, then the form is in edit mode. Otherwise, it is in creation mode. Based on this logic, we change the heading of the form accordingly.<\/p>\n\n\n\n<p>Fourth, modify the <code>home.html<\/code> template to include the edit link in each post:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml shcb-code-table\"><span class='shcb-loc'><span>{% extends 'base.html' %}\n<\/span><\/span><span class='shcb-loc'><span>\t\n<\/span><\/span><span class='shcb-loc'><span>{% block content %}\n<\/span><\/span><span class='shcb-loc'><span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h1<\/span>&gt;<\/span>My Posts<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h1<\/span>&gt;<\/span>\n<\/span><\/span><span class='shcb-loc'><span>\t{% for post in posts %}\n<\/span><\/span><span class='shcb-loc'><span>\t\t<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h2<\/span>&gt;<\/span>{{ post.title }}<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h2<\/span>&gt;<\/span>\n<\/span><\/span><span class='shcb-loc'><span>\t\t<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">small<\/span>&gt;<\/span>Published on {{ post.published_at | date:\"M d, Y\" }} by {{ post.author | title}}<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">small<\/span>&gt;<\/span>\n<\/span><\/span><span class='shcb-loc'><span>\t\t<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">p<\/span>&gt;<\/span>{{ post.content }}<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">p<\/span>&gt;<\/span>\n<\/span><\/span><mark class='shcb-loc'><span>\t\t<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">p<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">a<\/span> <span class=\"hljs-attr\">href<\/span>=<span class=\"hljs-string\">\"{% url 'post-edit' post.id %}\"<\/span>&gt;<\/span>Edit<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">a<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">p<\/span>&gt;<\/span>\n<\/span><\/mark><span class='shcb-loc'><span>\t{% endfor %}\n<\/span><\/span><span class='shcb-loc'><span>{% endblock content %}\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Fifth, open the post list URL <code>http:\/\/127.0.0.1\/<\/code>, you&#8217;ll see a list of posts with the edit link on each as shown in the following picture:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"460\" height=\"453\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2022\/11\/django-edit-form-add-edit-link.png\" alt=\"django edit form - add edit link\" class=\"wp-image-5879\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2022\/11\/django-edit-form-add-edit-link.png 460w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2022\/11\/django-edit-form-add-edit-link-300x295.png 300w\" sizes=\"auto, (max-width: 460px) 100vw, 460px\" \/><\/figure>\n\n\n\n<p>If you click the Edit link to edit a post, you&#8217;ll see a form populated with field values. For example, you can edit the post &#8220;Flat is better than nested&#8221;, you&#8217;ll see the following form:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"505\" height=\"462\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2022\/11\/django-edit-form-edit-form-with-values.png\" alt=\"\" class=\"wp-image-5880\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2022\/11\/django-edit-form-edit-form-with-values.png 505w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2022\/11\/django-edit-form-edit-form-with-values-300x274.png 300w\" sizes=\"auto, (max-width: 505px) 100vw, 505px\" \/><\/figure>\n\n\n\n<p>To edit the post, you change the values and click the Save button. However, we haven&#8217;t added the code that handles the HTTP POST request yet.<\/p>\n\n\n\n<p>Sixth, add the code that handles the HTTP POST request i.e. when the Save button is clicked:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python shcb-code-table\"><span class='shcb-loc'><span><span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">edit_post<\/span><span class=\"hljs-params\">(request, id)<\/span>:<\/span>\n<\/span><\/span><span class='shcb-loc'><span>    post = get_object_or_404(Post, id=id)\n<\/span><\/span><span class='shcb-loc'><span>\n<\/span><\/span><span class='shcb-loc'><span>    <span class=\"hljs-keyword\">if<\/span> request.method == <span class=\"hljs-string\">'GET'<\/span>:\n<\/span><\/span><span class='shcb-loc'><span>        context = {<span class=\"hljs-string\">'form'<\/span>: PostForm(instance=post), <span class=\"hljs-string\">'id'<\/span>: id}\n<\/span><\/span><span class='shcb-loc'><span>        <span class=\"hljs-keyword\">return<\/span> render(request,<span class=\"hljs-string\">'blog\/post_form.html'<\/span>,context)\n<\/span><\/span><span class='shcb-loc'><span>    \n<\/span><\/span><mark class='shcb-loc'><span>    <span class=\"hljs-keyword\">elif<\/span> request.method == <span class=\"hljs-string\">'POST'<\/span>:\n<\/span><\/mark><mark class='shcb-loc'><span>        form = PostForm(request.POST, instance=post)\n<\/span><\/mark><mark class='shcb-loc'><span>        <span class=\"hljs-keyword\">if<\/span> form.is_valid():\n<\/span><\/mark><mark class='shcb-loc'><span>            form.save()\n<\/span><\/mark><mark class='shcb-loc'><span>            messages.success(request, <span class=\"hljs-string\">'The post has been updated successfully.'<\/span>)\n<\/span><\/mark><mark class='shcb-loc'><span>            <span class=\"hljs-keyword\">return<\/span> redirect(<span class=\"hljs-string\">'posts'<\/span>)\n<\/span><\/mark><mark class='shcb-loc'><span>        <span class=\"hljs-keyword\">else<\/span>:\n<\/span><\/mark><mark class='shcb-loc'><span>            messages.error(request, <span class=\"hljs-string\">'Please correct the following errors:'<\/span>)\n<\/span><\/mark><mark class='shcb-loc'><span>            <span class=\"hljs-keyword\">return<\/span> render(request,<span class=\"hljs-string\">'blog\/post_form.html'<\/span>,{<span class=\"hljs-string\">'form'<\/span>:form})\n<\/span><\/mark><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Update the post by appending three asterisks (***) to the title:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"505\" height=\"474\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2022\/11\/django-edit-form-update-post.png\" alt=\"\" class=\"wp-image-5881\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2022\/11\/django-edit-form-update-post.png 505w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2022\/11\/django-edit-form-update-post-300x282.png 300w\" sizes=\"auto, (max-width: 505px) 100vw, 505px\" \/><\/figure>\n\n\n\n<p>Click the Save button and you&#8217;ll see that the post will be updated:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"483\" height=\"496\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2022\/11\/django-edit-form-post-updated.png\" alt=\"\" class=\"wp-image-5882\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2022\/11\/django-edit-form-post-updated.png 483w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2022\/11\/django-edit-form-post-updated-292x300.png 292w\" sizes=\"auto, (max-width: 483px) 100vw, 483px\" \/><\/figure>\n\n\n\n<p class=\"note\"><a href=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/01\/django_project_9.zip\" target=\"_blank\" rel=\"noreferrer noopener\">Download the Django Project source code<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Include <code>&lt;int:id&gt;<\/code> pattern in a URL to create an editing URL that accepts a model id as an integer.<\/li>\n\n\n\n<li>Use the <code>get_object_or_404()<\/code> function to get an object by id or redirect to the 404 page if the object doesn&#8217;t exist.<\/li>\n\n\n\n<li>Pass a model instance to a model form to render the model fields.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful ?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"5875\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pythontutorial.net\/django-tutorial\/django-edit-form\/\"\n\t\t\t\tdata-post-title=\"Django Edit Form\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"5875\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pythontutorial.net\/django-tutorial\/django-edit-form\/\"\n\t\t\t\tdata-post-title=\"Django Edit Form\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\t\t\t<input type=\"button\" name=\"wth-submit\" class=\"wth-btn wth-btn-submit\" id=\"wth-submit\" \/>\n\t\t\t<input type=\"button\" class=\"wth-btn wth-btn-cancel\" value=\"Cancel\" \/>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you&#8217;ll learn how to create a Django edit form to edit a post and save the changes into the database.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":5531,"menu_order":8,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-5875","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/5875","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/comments?post=5875"}],"version-history":[{"count":0,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/5875\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/5531"}],"wp:attachment":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/media?parent=5875"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}