title: Django Urls - two views with same regular expression
body: <p>I have two views with the same regular expression, as you can see below. It's a Category and an Article view, their entry slugs will never be the same so it should be no problem. But at the moment it doesn't work well, as you prolly know the category-view will get triggered.</p>
  
  <p><em>Please do not suggest to make the url structure unique, the slugs of categories and articles will never be the same. It should be as short as possible.</em></p>
  
  <p><strong>urls.py</strong></p>
  
  <pre><code>urlpatterns = [
      url(r'^index', index.Index.as_view(), name='index'),
      url(r'^search', search.Index.as_view(), name='search'),
      url(r'^(?P&lt;slug&gt;.+)$', category.Index.as_view(), name='category'),
      url(r'^(?P&lt;slug&gt;.+)$', article.Index.as_view(), name='article'),
  ]
  </code></pre>
  
  <p>I tried to reverse from views.category back to urls.py if there is no category to find like this:</p>
  
  <p><strong>views.category.py</strong></p>
  
  <pre><code>class Index(View):
      def get(self, request, slug):
          category = CategoryModel.objects.get(slug=slug)
          if category is None:
              return HttpResponseRedirect(reverse('article', args=[slug]))
  
          context = {
              'category': category
          }
          return render(request, 'category/index.html', context)
  </code></pre>
  
  <p><strong>The error</strong> (but there is a article with slug 'test123'):</p>
  
  <pre><code>NoReverseMatch at /wiki/test123
  Reverse for 'article' with arguments '('test123',)' and keyword arguments '{}' not found. 0 pattern(s) tried: []
  </code></pre>
  
  <p>Using Python 3.6</p>