| 586 | .. attribute:: ModelAdmin.change_list_template |
| 587 | |
| 588 | .. versionadded:: 1.0 |
| 589 | |
| 590 | Path to a custom template that will be used by the model objects "change list" |
| 591 | view. The template file searching order and precedence rules and modular |
| 592 | extension strategy recommendations outlined in the `Overriding Admin Templates`_ |
| 593 | section apply here. |
| 594 | |
| 595 | If you don't specify it, a default template shipped with Django that provides |
| 596 | the standard appearance is used. |
| 597 | |
| 598 | .. attribute:: ModelAdmin.change_form_template |
| 599 | |
| 600 | .. versionadded:: 1.0 |
| 601 | |
| 602 | Path to a custom template that will be used by both the model object creation |
| 603 | and change views. The template file searching order and precedence rules and |
| 604 | modular extension strategy recommendations outlined in the `Overriding Admin |
| 605 | Templates`_ section apply here. |
| 606 | |
| 607 | If you don't specify it, a default template shipped with Django that provides |
| 608 | the standard appearance is used. |
| 609 | |
| 610 | .. attribute:: ModelAdmin.object_history_template |
| 611 | |
| 612 | .. versionadded:: 1.0 |
| 613 | |
| 614 | Path to a custom template that will be used by the model object change history |
| 615 | display view. The template file searching order and precedence rules and modular |
| 616 | extension strategy recommendations outlined in the `Overriding Admin Templates`_ |
| 617 | section apply here. |
| 618 | |
| 619 | If you don't specify it, a default template shipped with Django that provides |
| 620 | the standard appearance is used. |
| 621 | |
| 622 | .. attribute:: ModelAdmin.delete_confirmation_template |
| 623 | |
| 624 | .. versionadded:: 1.0 |
| 625 | |
| 626 | Path to a custom template that will be used by the view responsible of showing |
| 627 | the confirmation page when the user decides to delete one or more model objects. |
| 628 | The template file searching order and precedence rules and modular extension |
| 629 | strategy recommendations outlined in the `Overriding Admin Templates`_ section |
| 630 | apply here. |
| 631 | |
| 632 | If you don't specify it, a default template shipped with Django that provides |
| 633 | the standard appearance is used. |
| 634 | |
| 668 | Other methods |
| 669 | ~~~~~~~~~~~~~ |
| 670 | |
| 671 | .. method:: ModelAdmin.add_view(self, request, form_url='', extra_context=None) |
| 672 | |
| 673 | Django view for the model instance addition page. See note below. |
| 674 | |
| 675 | .. method:: ModelAdmin.change_view(self, request, object_id, extra_context=None) |
| 676 | |
| 677 | Django view for the model instance edition page. See note below. |
| 678 | |
| 679 | .. method:: ModelAdmin.changelist_view(self, request, extra_context=None) |
| 680 | |
| 681 | Django view for the model instances change list/actions page. See note below. |
| 682 | |
| 683 | .. method:: ModelAdmin.delete_view(self, request, object_id, extra_context=None) |
| 684 | |
| 685 | Django view for the model instance(s) deletion confirmation page. See note below. |
| 686 | |
| 687 | .. method:: ModelAdmin.history_view(self, request, object_id, extra_context=None) |
| 688 | |
| 689 | Django view for the page that shows the modification history for a given model |
| 690 | instance. |
| 691 | |
| 692 | Unlike the hook-type ``ModelAdmin`` methods detailed in the previous section, |
| 693 | these five methods are in reality designed to be invoked as Django views from |
| 694 | the admin application URL dispatching handler to render the pages that deal |
| 695 | with model instancies CRUD operations. Because of that they implement the |
| 696 | complex logic specific to the generic nature of the admin app and there aren't |
| 697 | many possibilities to customize their behavior other than replace their |
| 698 | implementation. |
| 699 | |
| 700 | .. versionadded:: 1.0 |
| 701 | |
| 702 | Nonetheless, you still can customize the presentation of their respective pages |
| 703 | (possibly transforming them completely) if needed: For this, you override the |
| 704 | method in your ``ModelAdmin`` subclass to augment the context provided to the |
| 705 | template layer using its ``extra_context`` parameter and at the same time |
| 706 | override the associated template used by the admin with the respective |
| 707 | ``*_template`` option described in the `ModelAdmin options`_ section. An |
| 708 | example:: |
| 709 | |
| 710 | class MyModelAdmin(admin.ModelAdmin): |
| 711 | |
| 712 | # A template for a very customized change view: |
| 713 | change_form_template = 'admin/myapp/extras/openstreetmap_change_form.html' |
| 714 | |
| 715 | def get_osm_info(self): |
| 716 | # ... |
| 717 | |
| 718 | def change_view(self, request, form_url='', extra_context=None): |
| 719 | my_context = { |
| 720 | 'osm_data': self.get_osm_info(), |
| 721 | } |
| 722 | return super(MyModelAdmin, self).change_view(request, |
| 723 | extra_context=my_context) |
| 724 | |
| 1112 | ``AdminSite`` attributes |
| 1113 | ------------------------ |
| 1114 | |
| 1115 | .. attribute:: AdminSite.index_template |
| 1116 | |
| 1117 | .. versionadded:: 1.0 |
| 1118 | |
| 1119 | Path to a custom template that will be used by the admin site main index view. |
| 1120 | The template file searching order and precedence rules and modular extension |
| 1121 | strategy recommendations outlined in the `Overriding Admin Templates`_ section |
| 1122 | apply here. |
| 1123 | |
| 1124 | .. attribute:: AdminSite.login_template |
| 1125 | |
| 1126 | .. versionadded:: 1.0 |
| 1127 | |
| 1128 | Path to a custom template that will be used by the admin site login view. |
| 1129 | The template file searching order and precedence rules and modular extension |
| 1130 | strategy recommendations outlined in the `Overriding Admin Templates`_ section |
| 1131 | apply here. |
| 1132 | |