Django: Print url of view without hardcoding the url
<p>Can i print out a url <code>/admin/manage/products/add</code> of a certain view in a template?</p>

<p>Here is the rule i want to create a link for</p>

<pre><code>(r'^manage/products/add/$', create_object, {'model': Product, 'post_save_redirect': ''}),
</code></pre>

<p>I would like to have /manage/products/add in a template without hardcoding it. How can i do this?</p>

<p><strong>Edit:</strong> I am not using the default admin (well, i am but it is at another url), this is my own</p>

<p>You can use <code>get_absolute_url</code>, but that will only work for a particular object.  Since your object hasn't been created yet, it won't work in this case.</p>

<p>You want to use <a href="https://docs.djangoproject.com/en/1.2/topics/http/urls/#naming-url-patterns" rel="nofollow">named URL patterns</a>.  Here's a quick intro:</p>

<p>Change the line in your urls.py to:</p>

<pre><code>(r'^manage/products/add/$', create_object, {'model': Product, 'post_save_redirect': ''}, "create-product"),
</code></pre>

<p>Then, in your template you use this to display the URL:</p>

<pre><code>{% url create-product %}
</code></pre>

<p>If you're using Django 1.5 or higher you need this:</p>

<pre><code>{% url 'create-product' %}
</code></pre>

<p>You can do some more powerful things with named URL patterns, they're very handy.  Note that they are only in the development version (and also 1.0).</p>
