title: How to append prefix to all url names when using include function - django
body: <p>I want to include some django app's urls, in two different parent routes. The problem is, if I try to do this, then I will not be able to use <code>reverse</code> function properly for that app's urls.</p>
  
  <p>This is where I'm stuck. The following url configurations will result in creation of two different url sets, e.g:</p>
  
  <pre><code>/api/v4/auth/{login, register, ...}
  /api/auth/{login, register, ...}
  </code></pre>
  
  <p>app A (urls.py)</p>
  
  <pre class="lang-py prettyprint-override"><code>from auth import views
  
  urlpatterns = [
      url(r'^login/', views.login, name='login'),
      url(r'^register/', views.register, name='register'),
      ...
  ]
  </code></pre>
  
  <p>main app (urls.py)</p>
  
  <pre class="lang-py prettyprint-override"><code>from auth import urls as auth_urls
  
  urlpatterns = [
      url(r'^api/v4/auth/', include(auth_urls)),
      url(r'^api/auth/', include(auth_urls)),
      ...
  ]
  </code></pre>
  
  <p>Now, if I try to use <code>reverse</code> function like below:</p>
  
  <pre class="lang-py prettyprint-override"><code>def get_login_url():
      return reverse('login')
  </code></pre>
  
  <p>I would probably get one of the possible outputs which I don't know how to control!</p>
  
  <p>I don't know if django supports appending some kind of prefix to names of the urls that are being included or is there any tricks to hack around it or not!</p>