Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Update doc example for overriding change_form.html

Slightly reworded another related paragraph for clarity, too.
  • Loading branch information...
commit 3f890f8dc707eac30a72b7f79981d79e17ba0ff4 1 parent a051a9d
Chris Beaven authored

Showing 1 changed file with 16 additions and 15 deletions. Show diff stats Hide diff stats

  1. 31  docs/ref/contrib/admin/index.txt
31  docs/ref/contrib/admin/index.txt
@@ -1790,31 +1790,32 @@ Because of the modular design of the admin templates, it is usually neither
1790 1790
 necessary nor advisable to replace an entire template. It is almost always
1791 1791
 better to override only the section of the template which you need to change.
1792 1792
 
1793  
-To continue the example above, we want to add a new link next to the ``History``
1794  
-tool for the ``Page`` model. After looking at ``change_form.html`` we determine
1795  
-that we only need to override the ``object-tools`` block. Therefore here is our
1796  
-new ``change_form.html`` :
  1793
+To continue the example above, we want to add a new link next to the
  1794
+``History`` tool for the ``Page`` model. After looking at ``change_form.html``
  1795
+we determine that we only need to override the ``object-tools-items`` block.
  1796
+Therefore here is our new ``change_form.html`` :
1797 1797
 
1798 1798
 .. code-block:: html+django
1799 1799
 
1800 1800
     {% extends "admin/change_form.html" %}
1801  
-    {% load i18n %}
1802  
-    {% block object-tools %}
1803  
-    {% if change %}{% if not is_popup %}
1804  
-      <ul class="object-tools">
1805  
-        <li><a href="history/" class="historylink">{% trans "History" %}</a></li>
1806  
-        <li><a href="mylink/" class="historylink">My Link</a></li>
  1801
+    {% load i18n admin_urls %}
  1802
+    {% block object-tools-items %}
  1803
+        <li>
  1804
+            <a href="{% url opts|admin_urlname:'history' original.pk|admin_urlquote %}" class="historylink">{% trans "History" %}</a>
  1805
+        </li>
  1806
+        <li>
  1807
+            <a href="mylink/" class="historylink">My Link</a>
  1808
+        </li>
1807 1809
         {% if has_absolute_url %}
1808  
-            <li><a href="../../../r/{{ content_type_id }}/{{ object_id }}/" class="viewsitelink">
1809  
-                {% trans "View on site" %}</a>
  1810
+            <li>
  1811
+                <a href="{% url 'admin:view_on_site' content_type_id original.pk %}" class="viewsitelink">{% trans "View on site" %}</a>
1810 1812
             </li>
1811 1813
         {% endif%}
1812  
-      </ul>
1813  
-    {% endif %}{% endif %}
1814 1814
     {% endblock %}
1815 1815
 
1816 1816
 And that's it! If we placed this file in the ``templates/admin/my_app``
1817  
-directory, our link would appear on every model's change form.
  1817
+directory, our link would appear on the change form for all models within
  1818
+my_app.
1818 1819
 
1819 1820
 Templates which may be overridden per app or model
1820 1821
 --------------------------------------------------

0 notes on commit 3f890f8

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