8000 Delete a Post done. · moktadirul-raju/DjangoBlog@3d10058 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3d10058

Browse files
committed
Delete a Post done.
1 parent 40f1129 commit 3d10058

37 files changed

+10
-1
lines changed
10 Bytes
Binary file not shown.
10 Bytes
Binary file not shown.
10 Bytes
Binary file not shown.
67 Bytes
Binary file not shown.
210 Bytes
Binary file not shown.
Binary file not shown.

backend/urls.py

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
path('posts/', views.posts, name='posts'),
88
path('new_post/', views.new_post, name='new_post'),
99
path('edit_post/<int:pk>/', views.edit_post, name='edit_post'),
10+
path('delete_post/<int:pk>/', views.delete_post, name='delete_post'),
1011
path('users/', views.users, name='users'),
1112
path('comments/', views.comments, name='comments'),
1213
path('tags/', views.tags, name='tags'),

backend/views.py

+7
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ def edit_post(request, pk):
4545
my_dict = {'post':post, 'edit_post':'edit_post'}
4646
return render(request, 'backend/posts.html', context=my_dict)
4747

48+
# Post Delete View
49+
def delete_post(request, pk):
50+
post = Post.objects.get(id=pk)
51+
post.delete()
52+
53+
return HttpResponseRedirect(reverse('backend:posts'))
54+
4855
def comments(request):
4956
comments = Comment.objects.all();
5057
my_dict = {'comments':comments}
10 Bytes
Binary file not shown.

blog/__pycache__/admin.cpython-37.pyc

10 Bytes
Binary file not shown.
Binary file not shown.

blog/__pycache__/forms.cpython-37.pyc

10 Bytes
Binary file not shown.
10 Bytes
Binary file not shown.

blog/__pycache__/urls.cpython-37.pyc

10 Bytes
Binary file not shown.

blog/__pycache__/views.cpython-37.pyc

10 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 Bytes
Binary file not shown.
10 Bytes
Binary file not shown.
10 Bytes
Binary file not shown.
10 Bytes
Binary file not shown.

db.sqlite3

0 Bytes
Binary file not shown.

templates/backend/posts.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
<td>{{post.status}}</td>
3434
<td>
3535
<a href="/backend/edit_post/{{post.id}}" class="btn btn-success">edit</a>
36-
<button class="btn btn-danger">delete</button>
36+
<a href="/backend/delete_post/{{post.id}}" class="btn btn-danger">delete</a>
37+
3738
</td>
3839
<td></td>
3940
</tr>

0 commit comments

Comments
 (0)
0