title: Django Using reverse() with multiple URLs that include the same app
body: <p>EDIT: I'm using rest_framework.reverse and providing the app name not the namespace for the reverse lookup. An example reverse call is:</p>
  
  <pre><code>reverse('api_app:system-detail', kwargs={...}, request=self.context.get('request'))
  </code></pre>
  
  <p>So I have a django project with a single app, and I have two different url patterns mapped to this one app. I currently have this mostly working, however for a few cases using reverse() results in the wrong namespace. My base urls.py looks like this:</p>
  
  <pre><code>from django.conf.urls import url, include
  from django.views.generic.base import RedirectView
  
  
  urlpatterns = [
      url(r'^api/', include('api_project.api_app.urls', 
      namespace='api')),
      url(r'^beta/api/', include('api_project.api_app.urls', 
      namespace='beta')),
      url(r'^$', RedirectView.as_view(url='api', permanent=False), 
      name='index')
  ]
  </code></pre>
  
  <p>EDIT: api_app.urls looks like:</p>
  
  <pre><code>from django.conf.urls import url
  from rest_framework.urlpatterns import format_suffix_patterns
  from . import views
  from rest_framework.schemas import get_schema_view
  
  schema_view = get_schema_view(title="Schema")
  
  
  app_name = 'api_app'
  
  urlpatterns = [
  url(r'^$', views.APIRoot.as_view(), name='api-root'),
  url(r'^schema/$', schema_view, name'api-schema'),
  ....
  </code></pre>
  
  <p>In most cases reverse works as expected, e.g. using /beta/endpoint has links on the page that look like: </p>
  
  <pre><code>/beta/endpoint/example
  </code></pre>
  
  <p>However, in a few cases using /beta/endpoint has links like: </p>
  
  <pre><code>/api/endpoint/different-example
  </code></pre>
  
  <p>My question is less about how reverse determines which namespace to use, but instead is this the appropriate way to use two namespaces for the same app? Is this something I should approach completely differently? </p>
  
  <p>Most of my research so far has not resulted in much success, so I'm thinking this might be fundamentally the wrong approach. </p>
  
  <p>If this approach is okay, then I'm curious why reverse is inconsistent in which namespace it returns.</p>