Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Defined path to post page
- # path('<slug:category_slug>/<slug:post_slug>/', views.PostDetailView.as_view(), name="post.detail")
- # Check:
- # 1. Is there a category with the given slug
- # 2. Is there a post whith the given slug
- class PostDetailView(generic.DetailView):
- model = Category
- template_name = "blogs/posts/detail.html"
- slug_url_kwarg = "category_slug"
- def get_context_data(self, **kwargs):
- context = super().get_context_data(**kwargs)
- context['post'] = get_object_or_404(Post, slug=self.kwargs['post_slug']) # Here I have doubts
- return context
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement