#8564: newforms-admin doesn't support linking to it via {% url %} or reverse()
----------------------------------------+-----------------------------------
Reporter: semenov | Owner: nobody
Status: new | Milestone:
Component: Admin interface | Version: SVN
Keywords: newforms-admin reverse url | Stage: Unreviewed
Has_patch: 0 |
----------------------------------------+-----------------------------------
In the old admin, that was possible to have a link to the admin area in
the UI, like:
{{{
{% if user.is_staff %}
<a href="{% url django.contrib.admin.views.main.index %}">Admin
area</a>
{% endif %}
}}}
or even:
{{{
<a href="{% url django.contrib.admin.views.main.change_stage
"app","model",instance.id %}">Edit instance</a>
}}}
In newforms-admin, that crashes with:
{{{
Reverse for 'src.django.contrib.admin.site.root' not found.
}}}
I do realize that admin.site is now a Site instance, not a module, that's
why {% url %} will never work for it.
However, I can't see how to put a link to the admin area now?
Currently I'm using the following hack:
{{{
#!python
urlpatterns = # ...
#(r'^admin/(.*)', admin.site.root),
(r'^admin/(.*)', 'views.admin_site_root'),
# ...
def admin_site_root(request, url):
return admin.site.root(request, url)
}}}
and then:
{{{
<a href="{% url views.admin_site_root "" %}">Admin</a>
}}}
which is pretty ugly (since of complete redundancy) but solves the
problem.
I defenitely think there should be a standard way to pull the admin site
urls. I can suggest two approaches:
1. Extend reverse() and {% url %} to recognize/understand bound methods,
in particular django.contrib.admin.site.root
2. Under django.contrib.admin.templatetags, create a set of tags like {%
admin django.contrib.admin.site %} and {% admin_change_list
django.contrib.site "app","model" %}
--
Ticket URL: <http://code.djangoproject.com/ticket/8564>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---