title: How do I use the {% url %} tag in a library app?
body: <p>How do I use the <code>{% url .. %}</code> template tag in a &quot;library&quot; app to create a link to the library-app's own views?</p>
  <p>Given a site with <code>mysite/urls.py</code>:</p>
  <pre><code>urlpatterns = [
      url(r'^myapp/', include('myapp.urls', namespace='mysite')),
  ]
  </code></pre>
  <p>and an app with <code>myapp/urls.py</code>:</p>
  <pre><code>urlpatterns = [
      url(r'^mylib/', include('mylib.urls', namespace='mylib')),
  ]
  </code></pre>
  <p>and the library app with <code>mylib/urls.py</code>:</p>
  <pre><code>urlpatterns = [
      url(r'^commands/$', views.commands, name='list-commands'),
      url(r'^command-1/$', views.command_1, name='command-1'),
  ]
  </code></pre>
  <p>where the <code>views.commands</code> view displays a template that should contain a link to <code>/myapp/mylib/command-1/</code>, ie. <code>mylib/templates/mylib/list-commands.html</code></p>
  <pre><code>&lt;a href='{% url &quot;command-1&quot; %}'&gt;command-1&lt;/a&gt;
  </code></pre>
  <p>It will of course work if I change it to:</p>
  <pre><code>{% url &quot;mysite:mylib:command-1&quot; %}
  </code></pre>
  <p>but the author of mylib doesn't know about neither mysite or myapp...?</p>
  <p>I have a feeling I've misunderstood something basic...</p>