diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index b52a82e61a..acc7d3962a 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -479,6 +479,7 @@ class ModelAdmin(BaseModelAdmin): 'content_type_id': ContentType.objects.get_for_model(model).id, 'save_as': self.save_as, 'save_on_top': self.save_on_top, + 'root_path': self.admin_site.root_path, }) return render_to_response(self.change_form_template or [ "admin/%s/%s/change_form.html" % (app_label, opts.object_name.lower()), @@ -537,6 +538,7 @@ class ModelAdmin(BaseModelAdmin): 'show_delete': False, 'media': mark_safe(media), 'inline_admin_formsets': inline_admin_formsets, + 'root_path': self.admin_site.root_path, } context.update(extra_context or {}) return self.render_change_form(request, model, context, add=True) @@ -613,6 +615,7 @@ class ModelAdmin(BaseModelAdmin): 'is_popup': request.REQUEST.has_key('_popup'), 'media': mark_safe(media), 'inline_admin_formsets': inline_admin_formsets, + 'root_path': self.admin_site.root_path, } context.update(extra_context or {}) return self.render_change_form(request, model, context, change=True, obj=obj) @@ -641,8 +644,9 @@ class ModelAdmin(BaseModelAdmin): 'title': cl.title, 'is_popup': cl.is_popup, 'cl': cl, + 'has_add_permission': self.has_add_permission(request), + 'root_path': self.admin_site.root_path, } - context.update({'has_add_permission': self.has_add_permission(request)}), context.update(extra_context or {}) return render_to_response(self.change_list_template or [ 'admin/%s/%s/change_list.html' % (app_label, opts.object_name.lower()), @@ -695,6 +699,7 @@ class ModelAdmin(BaseModelAdmin): "deleted_objects": deleted_objects, "perms_lacking": perms_needed, "opts": opts, + "root_path": self.admin_site.root_path, } context.update(extra_context or {}) return render_to_response(self.delete_confirmation_template or [ @@ -720,6 +725,7 @@ class ModelAdmin(BaseModelAdmin): 'action_list': action_list, 'module_name': capfirst(opts.verbose_name_plural), 'object': obj, + 'root_path': self.admin_site.root_path, } context.update(extra_context or {}) return render_to_response(self.object_history_template or [ diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py index ce14b269fb..b7bea355c7 100644 --- a/django/contrib/admin/sites.py +++ b/django/contrib/admin/sites.py @@ -94,11 +94,14 @@ class AdminSite(object): return request.user.is_authenticated() and request.user.is_staff def root(self, request, url): - """ + """ Handles main URL routing for the admin app. `url` is the remainder of the URL -- e.g. 'comments/comment/'. - """ + """ + # Figure out the admin base URL path and stash it for later use + self.root_path = re.sub(re.escape(url) + '$', '', request.path) + url = url.rstrip('/') # Trim trailing slash, if it exists. # The 'logout' view doesn't require that the person is logged in. @@ -295,6 +298,7 @@ class AdminSite(object): context = { 'title': _('Site administration'), 'app_list': app_list, + 'root_path': self.root_path, } context.update(extra_context or {}) return render_to_response(self.index_template or 'admin/index.html', context, @@ -316,7 +320,8 @@ class AdminSite(object): 'title': _('Log in'), 'app_path': request.path, 'post_data': post_data, - 'error_message': error_message + 'error_message': error_message, + 'root_path': self.root_path, } context.update(extra_context or {}) return render_to_response(self.login_template or 'admin/login.html', context, diff --git a/django/contrib/admin/templates/admin/auth/user/change_password.html b/django/contrib/admin/templates/admin/auth/user/change_password.html index 5740feb60f..f1c4a8d34a 100644 --- a/django/contrib/admin/templates/admin/auth/user/change_password.html +++ b/django/contrib/admin/templates/admin/auth/user/change_password.html @@ -5,7 +5,6 @@ {% endblock %} {% block stylesheet %}{% admin_media_prefix %}css/forms.css{% endblock %} {% block bodyclass %}{{ opts.app_label }}-{{ opts.object_name.lower }} change-form{% endblock %} -{% block userlinks %}{% trans 'Documentation' %} / {% trans 'Change password' %} / {% trans 'Log out' %}{% endblock %} {% block breadcrumbs %}{% if not is_popup %}
{% if user.is_authenticated and user.is_staff %} -