Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
wants to merge 1 commit into from

5 participants

Daniel Hepper Marc Tamlyn Danilo Bargen Florian Apolloner Julien Phalip
Marc Tamlyn
Collaborator

:+1:

Danilo Bargen

Looks OK to me.

Florian Apolloner
Owner

I personally would rename shortcut to something like object_shortcut.

Florian Apolloner
Owner

Aren't the jsi18n changes covered in #139 ?

Daniel Hepper

@apollo13 you are right, that was not intended. I removed the commit from the branch and updated with a forced push

Julien Phalip
Collaborator

That looks good to me. I'd just rename the url to 'view_on_site'.

Florian Apolloner apollo13 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
3  django/contrib/admin/sites.py
View
@@ -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')
2  django/contrib/admin/templates/admin/change_form.html
View
@@ -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 %}
2  django/contrib/admin/templates/admin/edit_inline/stacked.html
View
@@ -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 %}
2  django/contrib/admin/templates/admin/edit_inline/tabular.html
View
@@ -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 }}
21 docs/ref/contrib/admin/index.txt
View
@@ -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:
Something went wrong with that request. Please try again.