@@ -84,7 +84,7 @@ into these:
84
84
{{ post.published_date }}
85
85
</div>
86
86
{% else %}
87
- <form method="POST" action="{% url post_publish pk=post.pk %} class="post-form">{% csrf_token %}
87
+ <form method="POST" action="{% url ' post_publish' pk=post.pk %}" class="post-form">{% csrf_token %}
88
88
<button type="submit" class="post btn btn-info" name="publish">Publish</button>
89
89
</form>
90
90
{% endif %}
@@ -101,7 +101,7 @@ Now, let's take a look at the details of the form. We are using a new attribute,
101
101
Time to create a URL (in ` blog/urls.py ` ):
102
102
103
103
``` python
104
- path(' post/<pk>/publish/' , views.post_publish, name = ' post_publish' ),
104
+ path(' post/<int: pk>/publish/' , views.post_publish, name = ' post_publish' ),
105
105
```
106
106
107
107
and finally, a * view* (as always, in ` blog/views.py ` ):
@@ -137,7 +137,7 @@ Congratulations! You are almost there. The last step is adding a delete button!
137
137
Let's open ` blog/templates/blog/post_detail.html ` once again and add these lines:
138
138
139
139
``` django
140
- <form method="POST" action="{% url post_remove pk=post.pk %} class="post-form">{% csrf_token %}
140
+ <form method="POST" action="{% url ' post_remove' pk=post.pk %}" class="post-form">{% csrf_token %}
141
141
<button type="submit" class="post btn btn-danger" name="delete">
142
142
<span class="glyphicon glyphicon-remove"></span>
143
143
</button>
@@ -149,7 +149,7 @@ just under a line with the edit button.
149
149
Now we need a URL (` blog/urls.py ` ):
150
150
151
151
``` python
152
- path(' post/<pk>/remove/' , views.post_remove, name = ' post_remove' ),
152
+ path(' post/<int: pk>/remove/' , views.post_remove, name = ' post_remove' ),
153
153
```
154
154
155
155
Now, time for a view! Open ` blog/views.py ` and add this code:
0 commit comments