title: Django: one url search in two models (cbv)
body: <p>Using Django, I'm looking for a way to use one url patern (with slug) to query one model and if nothing is found query a second model. I'm using Class Based Views.</p>
  
  <p>I am following this <a href="https://stackoverflow.com/a/19119131/2426064">answer</a>, and the next View is being called. But then I get the following error:</p>
  
  <p>"Generic detail view must be called with either an object pk or a slug."</p>
  
  <p>I can't figure out how to pass the slug to the next View.</p>
  
  <p>My url:</p>
  
  <pre><code>url(r'^(?P&lt;slug&gt;[-\w]+)/$', SingleView.as_view(), name='singleview'),
  </code></pre>
  
  <p>My CBV's:</p>
  
  <pre><code>class SingleView(DetailView):
  
      def dispatch(self, request, *args, **kwargs):
      post_or_page_slug = kwargs.pop('slug')
  
      if Page.objects.filter(slug=post_or_page_slug).count() != 0:
          return PageDetailView.as_view()(request, *args, **kwargs)
      elif Post.objects.filter(slug=post_or_page_slug).count() != 0:
          return PostDetailView.as_view()(request, *args, **kwargs)
      else:
          raise Http404
  
  
  class PageDetailView(DetailView):
  
      model = Page
      template_name = 'page-detail.html'
  
  
  class PostDetailView(DetailView):
  
      model = Post
      template_name = 'post-detail.html'
  </code></pre>