admin url name

15 views
Skip to first unread message

Umapathy S

unread,
Feb 12, 2010, 4:34:40 PM2/12/10
to django...@googlegroups.com
Hello,

I am looking for the admin site url name to be included as a link in a home page template.

I looked at contrib/admin/sites.py

AdminSite sets self.name which is then passed to

       # Admin-site-wide views.
        urlpatterns = patterns('',
            url(r'^$',
                wrap(self.index),
                name='%sadmin_index' % self.name),


What is the self.name passed to AdminSite constructor.  I tried
        <li><a href="{% url admin_index %}"> Admin </a></li>

It throws a template syntax error.

Exception Value:
Caught an exception while rendering: Reverse for 'admin_index' with arguments '()' and keyword arguments '{}' not found.


Any help much appreciated.

Thanks

Umapathy

--The browser you can trust - Firefox 3

Karen Tracey

unread,
Feb 12, 2010, 11:43:48 PM2/12/10
to django...@googlegroups.com
On Fri, Feb 12, 2010 at 4:34 PM, Umapathy S <nsup...@gmail.com> wrote:
Hello,

I am looking for the admin site url name to be included as a link in a home page template.

I looked at contrib/admin/sites.py

AdminSite sets self.name which is then passed to

       # Admin-site-wide views.
        urlpatterns = patterns('',
            url(r'^$',
                wrap(self.index),
                name='%sadmin_index' % self.name),


What level of code are you running? That code you show was added during the development of 1.1 in r9739:

http://code.djangoproject.com/changeset/9739

but it was changed before the release of 1.1, in r11250:

http://code.djangoproject.com/changeset/11250

So you appear to be running an SVN checkout from sometime between January and July of 2009? If so, it's probably in your best interest to update to an official released version.
 

What is the self.name passed to AdminSite constructor.  I tried
        <li><a href="{% url admin_index %}"> Admin </a></li>

It throws a template syntax error.

Exception Value:
Caught an exception while rendering: Reverse for 'admin_index' with arguments '()' and keyword arguments '{}' not found.


Any help much appreciated.

I don't know how to get this working on the level of code you have. To do it with 1.1 or higher, you'd want to reverse admin:index, as documented here:

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#reversing-admin-urls

Karen

Umapathy S

unread,
Feb 13, 2010, 3:52:05 AM2/13/10
to django...@googlegroups.com
thanks Karen.

I tried as per the above document before mailing the list.

I had installed 1.1 beta but then switched to 1.1 final.

Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1, 1, 0, 'final', 0)

Somewhere it has gone wrong.  I will delete all the django packages and reinstall again.

Thanks

Umapathy
Reply all
Reply to author
Forward
0 new messages