Linking to the django admin site

Rowena picture Rowena · Jun 20, 2009 · Viewed 25k times · Source

Very basic question, but I'm having trouble tracking down the answer on the web. I have a template, which I want to link to the django admin site (i.e. localhost:8000/admin). What is the code for this?

I'm imagining something like

<a href="{% url admin.site.root %}">link to admin panel</a>

However, when I try the above snippet I get:

Caught an exception while rendering:
  Reverse for 'project_name.django.contrib.admin.sites.root' with
  arguments '()' and keyword arguments '{}' not found.

Help?

Answer

Romain picture Romain · Mar 12, 2010

Try what Oggy is suggesting but then use ':' instead of '_' with the current Django:

<a href="{% url 'admin:index' %}">link to admin panel</a>