SHARE
TWEET

Untitled

a guest Jul 21st, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top