Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #18444 -- Replace hard coded "View on Site" URLs

  • Loading branch information...
commit 015bcbce0e33c4a0d62d96d4a4d1f72bdd29b0a8 1 parent d2ad3b0
@dhepper dhepper authored
View
3  django/contrib/admin/sites.py
@@ -231,7 +231,8 @@ def wrapper(*args, **kwargs):
wrap(self.i18n_javascript, cacheable=True),
name='jsi18n'),
url(r'^r/(?P<content_type_id>\d+)/(?P<object_id>.+)/$',
- wrap(contenttype_views.shortcut)),
+ wrap(contenttype_views.shortcut),
+ name='shortcut'),
url(r'^(?P<app_label>\w+)/$',
wrap(self.app_index),
name='app_list')
View
2  django/contrib/admin/templates/admin/change_form.html
@@ -31,7 +31,7 @@
<ul class="object-tools">
{% block object-tools-items %}
<li><a href="history/" class="historylink">{% trans "History" %}</a></li>
- {% if has_absolute_url %}<li><a href="../../../r/{{ content_type_id }}/{{ original.pk }}/" class="viewsitelink">{% trans "View on site" %}</a></li>{% endif%}
+ {% if has_absolute_url %}<li><a href="{% url 'admin:shortcut' content_type_id original.pk %}" class="viewsitelink">{% trans "View on site" %}</a></li>{% endif%}
{% endblock %}
</ul>
{% endif %}{% endif %}
View
2  django/contrib/admin/templates/admin/edit_inline/stacked.html
@@ -6,7 +6,7 @@
{% for inline_admin_form in inline_admin_formset %}<div class="inline-related{% if forloop.last %} empty-form last-related{% endif %}" id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
<h3><b>{{ inline_admin_formset.opts.verbose_name|title }}:</b>&nbsp;<span class="inline_label">{% if inline_admin_form.original %}{{ inline_admin_form.original }}{% else %}#{{ forloop.counter }}{% endif %}</span>
- {% if inline_admin_form.show_url %}<a href="../../../r/{{ inline_admin_form.original_content_type_id }}/{{ inline_admin_form.original.pk }}/">{% trans "View on site" %}</a>{% endif %}
+ {% if inline_admin_form.show_url %}<a href="{% url 'admin:shortcut' inline_admin_form.original_content_type_id inline_admin_form.original.pk %}">{% trans "View on site" %}</a>{% endif %}
{% if inline_admin_formset.formset.can_delete and inline_admin_form.original %}<span class="delete">{{ inline_admin_form.deletion_field.field }} {{ inline_admin_form.deletion_field.label_tag }}</span>{% endif %}
</h3>
{% if inline_admin_form.form.non_field_errors %}{{ inline_admin_form.form.non_field_errors }}{% endif %}
View
2  django/contrib/admin/templates/admin/edit_inline/tabular.html
@@ -27,7 +27,7 @@
<td class="original">
{% if inline_admin_form.original or inline_admin_form.show_url %}<p>
{% if inline_admin_form.original %} {{ inline_admin_form.original }}{% endif %}
- {% if inline_admin_form.show_url %}<a href="../../../r/{{ inline_admin_form.original_content_type_id }}/{{ inline_admin_form.original.pk }}/">{% trans "View on site" %}</a>{% endif %}
+ {% if inline_admin_form.show_url %}<a href="{% url 'admin:shortcut' inline_admin_form.original_content_type_id inline_admin_form.original.pk %}">{% trans "View on site" %}</a>{% endif %}
</p>{% endif %}
{% if inline_admin_form.has_auto_field %}{{ inline_admin_form.pk_field.field }}{% endif %}
{{ inline_admin_form.fk_field.field }}
View
21 docs/ref/contrib/admin/index.txt
@@ -1948,16 +1948,17 @@ accessible using Django's :ref:`URL reversing system <naming-url-patterns>`.
The :class:`AdminSite` provides the following named URL patterns:
-====================== ======================== =============
-Page URL name Parameters
-====================== ======================== =============
-Index ``index``
-Logout ``logout``
-Password change ``password_change``
-Password change done ``password_change_done``
-i18n javascript ``jsi18n``
-Application index page ``app_list`` ``app_label``
-====================== ======================== =============
+========================= ======================== ==================================
+Page URL name Parameters
+========================= ======================== ==================================
+Index ``index``
+Logout ``logout``
+Password change ``password_change``
+Password change done ``password_change_done``
+i18n javascript ``jsi18n``
+Application index page ``app_list`` ``app_label``
+Redirect to object's page ``shortcut`` ``content_type_id``, ``object_id``
+========================= ======================== ==================================
Each :class:`ModelAdmin` instance provides an additional set of named URLs:

0 comments on commit 015bcbc

Please sign in to comment.
Something went wrong with that request. Please try again.