Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.0.X] Fixed #10415 -- Added documentation for features added in r76…

…27 and r7630; extensibility points for the ModelAdmin?? and AdminSite??. Thanks to Ramiro Morales for the draft text.

Merge of r11095 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@11100 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 60ec0bdec2e3eb4367b6a3687db3b52936353cf2 1 parent e717ddc
Russell Keith-Magee authored June 24, 2009

Showing 1 changed file with 106 additions and 4 deletions. Show diff stats Hide diff stats

  1. 110  docs/ref/contrib/admin.txt
110  docs/ref/contrib/admin.txt
@@ -583,6 +583,43 @@ with an operator:
583 583
     Performs a full-text match. This is like the default search method but uses
584 584
     an index. Currently this is only available for MySQL.
585 585
 
  586
+.. attribute:: ModelAdmin.change_list_template
  587
+
  588
+Path to a custom template that will be used by the model objects "change list"
  589
+view. Templates can override or extend base admin templates as described in
  590
+`Overriding Admin Templates`_.
  591
+
  592
+If you don't specify this attribute, a default template shipped with Django
  593
+that provides the standard appearance is used.
  594
+
  595
+.. attribute:: ModelAdmin.change_form_template
  596
+
  597
+Path to a custom template that will be used by both the model object creation
  598
+and change views. Templates can override or extend base admin templates as
  599
+described in `Overriding Admin Templates`_.
  600
+
  601
+If you don't specify this attribute, a default template shipped with Django
  602
+that provides the standard appearance is used.
  603
+
  604
+.. attribute:: ModelAdmin.object_history_template
  605
+
  606
+Path to a custom template that will be used by the model object change history
  607
+display view. Templates can override or extend base admin templates as
  608
+described in `Overriding Admin Templates`_.
  609
+
  610
+If you don't specify this attribute, a default template shipped with Django
  611
+that provides the standard appearance is used.
  612
+
  613
+.. attribute:: ModelAdmin.delete_confirmation_template
  614
+
  615
+Path to a custom template that will be used by the view responsible of showing
  616
+the confirmation page when the user decides to delete one or more model
  617
+objects. Templates can override or extend base admin templates as described in
  618
+`Overriding Admin Templates`_.
  619
+
  620
+If you don't specify this attribute, a default template shipped with Django
  621
+that provides the standard appearance is used.
  622
+
586 623
 ``ModelAdmin`` methods
587 624
 ----------------------
588 625
 
@@ -616,6 +653,56 @@ model instance::
616 653
                 instance.save()
617 654
             formset.save_m2m()
618 655
 
  656
+Other methods
  657
+~~~~~~~~~~~~~
  658
+
  659
+.. method:: ModelAdmin.add_view(self, request, form_url='', extra_context=None)
  660
+
  661
+Django view for the model instance addition page. See note below.
  662
+
  663
+.. method:: ModelAdmin.change_view(self, request, object_id, extra_context=None)
  664
+
  665
+Django view for the model instance edition page. See note below.
  666
+
  667
+.. method:: ModelAdmin.changelist_view(self, request, extra_context=None)
  668
+
  669
+Django view for the model instances change list/actions page. See note below.
  670
+
  671
+.. method:: ModelAdmin.delete_view(self, request, object_id, extra_context=None)
  672
+
  673
+Django view for the model instance(s) deletion confirmation page. See note below.
  674
+
  675
+.. method:: ModelAdmin.history_view(self, request, object_id, extra_context=None)
  676
+
  677
+Django view for the page that shows the modification history for a given model
  678
+instance.
  679
+
  680
+Unlike the hook-type ``ModelAdmin`` methods detailed in the previous section,
  681
+these five methods are in reality designed to be invoked as Django views from
  682
+the admin application URL dispatching handler to render the pages that deal
  683
+with model instances CRUD operations. As a result, completely overriding these
  684
+methods will significantly change the behavior of the admin application.
  685
+
  686
+One comon reason for overriding these methods is to augment the context data
  687
+that is provided to the template that renders the view. In the following
  688
+example, the change view is overridden so that the rendered template is
  689
+provided some extra mapping data that would not otherwise be available::
  690
+
  691
+    class MyModelAdmin(admin.ModelAdmin):
  692
+
  693
+        # A template for a very customized change view:
  694
+        change_form_template = 'admin/myapp/extras/openstreetmap_change_form.html'
  695
+
  696
+        def get_osm_info(self):
  697
+            # ...
  698
+
  699
+        def change_view(self, request, object_id, extra_context=None):
  700
+            my_context = {
  701
+                'osm_data': self.get_osm_info(),
  702
+            }
  703
+            return super(MyModelAdmin, self).change_view(request, object_id,
  704
+                extra_context=my_context))
  705
+
619 706
 ``ModelAdmin`` media definitions
620 707
 --------------------------------
621 708
 
@@ -960,7 +1047,7 @@ directory, our link would appear on every model's change form.
960 1047
 Templates which may be overridden per app or model
961 1048
 --------------------------------------------------
962 1049
 
963  
-Not every template in ``contrib\admin\templates\admin`` may be overridden per
  1050
+Not every template in ``contrib/admin/templates/admin`` may be overridden per
964 1051
 app or per model. The following can:
965 1052
 
966 1053
     * ``change_form.html``
@@ -983,9 +1070,10 @@ and 500 pages.
983 1070
 Root and login templates
984 1071
 ------------------------
985 1072
 
986  
-If you wish to change the index or login templates, you are better off creating
987  
-your own ``AdminSite`` instance (see below), and changing the ``index_template``
988  
-or ``login_template`` properties.
  1073
+If you wish to change the index or login templates, you are better off
  1074
+creating your own ``AdminSite`` instance (see below), and changing the
  1075
+:attr:`AdminSite.index_template` or :attr:`AdminSite.login_template`
  1076
+properties.
989 1077
 
990 1078
 ``AdminSite`` objects
991 1079
 =====================
@@ -1002,6 +1090,20 @@ or add anything you like. Then, simply create an instance of your
1002 1090
 Python class), and register your models and ``ModelAdmin`` subclasses
1003 1091
 with it instead of using the default.
1004 1092
 
  1093
+``AdminSite`` attributes
  1094
+------------------------
  1095
+
  1096
+.. attribute:: AdminSite.index_template
  1097
+
  1098
+Path to a custom template that will be used by the admin site main index view.
  1099
+Templates can override or extend base admin templates as described in
  1100
+`Overriding Admin Templates`_.
  1101
+
  1102
+.. attribute:: AdminSite.login_template
  1103
+
  1104
+Path to a custom template that will be used by the admin site login view.
  1105
+Templates can override or extend base admin templates as described in
  1106
+`Overriding Admin Templates`_.
1005 1107
 
1006 1108
 Hooking ``AdminSite`` instances into your URLconf
1007 1109
 -------------------------------------------------

0 notes on commit 60ec0bd

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