using slugs with class based view django code example
Example: class views django slug
class SinglePostByCategory(DetailView):
def get_queryset(self):
return get_object_or_404(Post,
category__slug=self.kwargs['category_slug'],
slug=self.kwargs['post_slug']
)