Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. # Defined path to post page
  2. # path('<slug:category_slug>/<slug:post_slug>/', views.PostDetailView.as_view(), name="post.detail")
  3.  
  4. # Check:
  5. # 1. Is there a category with the given slug
  6. # 2. Is there a post whith the given slug
  7. class PostDetailView(generic.DetailView):
  8. model = Category
  9. template_name = "blogs/posts/detail.html"
  10. slug_url_kwarg = "category_slug"
  11.  
  12. def get_context_data(self, **kwargs):
  13. context = super().get_context_data(**kwargs)
  14. context['post'] = get_object_or_404(Post, slug=self.kwargs['post_slug']) # Here I have doubts
  15.  
  16. return context
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement