From the django docs on url namespaces [1]

Namespaced URLs are specified using the : operator. For example, the main index page of the admin application is referenced using admin:index. This indicates a namespace of admin, and a named URL of index.

So you link to the admin index in your template using:

{% url admin:index %}

For Django 1.3, the documented way [2] to include the admin site is:

*url(r'^admin/', include(admin.site.urls)),*


Regards,
Alasdair Nicol

[1] https://docs.djangoproject.com/en/dev/topics/http/urls/#url-namespaces
[2] https://docs.djangoproject.com/en/1.3/intro/tutorial02/


On 14/07/11 15:35, eric.frederich wrote:
Hello,

I am moving from 1.0.2 to 1.3 and am having problems linking to the
admin site from within a template.
I used to have this in my template...

     <p><a href="{% url the-django-admin None %}">Django Admin</a>

And I used to have this in my urls.py

     url(r'^admin/(.*)'      , admin.site.root, name='the-django-
admin'),

I'm sure this was hacky even back in 1.0.2
How should I link to the admin site's index from within a template?

I cannot hard code it to /admin because while this would work on
development, on production it needs to be /apps/admin
So I need to use the URL resoving mechanism so that the prefix gets
picked up based on which environment it is on.

So... simple question.  How do I link to the Django admin site from
within a template?

Thanks,
~Eric



--
Alasdair Nicol
Developer, MEMSET

mail: alasd...@memset.com
 web: http://www.memset.com/

Memset Ltd., registration number 4504980. 25 Frederick Sanger Road, Guildford, 
Surrey, GU2 7YD, UK.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to