post_listthat displays only published blog posts (those with non-empty
blog/templates/blog/base.htmlin the header. We don't want to show our list of drafts to everybody, so we'll put it inside the `
posts = Post.objects.filter(published_date__isnull=True).order_by('created_date')makes sure that we take only unpublished posts (
published_date__isnull=True) and order them by
blog/templates/blog/post_draft_list.htmland add the following:
http://127.0.0.1:8000/drafts/you will see the list of unpublished posts.
blog/templates/blog/post_detail.htmland change these lines:
line here. That means, that if the condition from
is not fulfilled (so if there is nopublished_date
), then we want to do the line<a class="btn btn-default" href="
. Note that we are passing apk
variable in the
Postmodel we wrote a method
publish. It looked like this:
blog/templates/blog/post_detail.htmlonce again and add this line:
blog/views.pyand add this code:
.delete(). It is as simple as that!