MCPcopy
hub / github.com/django/django / ModelAdmin

Class ModelAdmin

django/contrib/admin/options.py:682–2664  ·  view source on GitHub ↗

Encapsulate all admin options and functionality for a given model.

Source from the content-addressed store, hash-verified

680
681
682class ModelAdmin(BaseModelAdmin):
683 """Encapsulate all admin options and functionality for a given model."""
684
685 list_display = ("__str__",)
686 list_display_links = ()
687 list_filter = ()
688 list_select_related = False
689 list_per_page = 100
690 list_max_show_all = 200
691 list_editable = ()
692 search_fields = ()
693 search_help_text = None
694 date_hierarchy = None
695 save_as = False
696 save_as_continue = True
697 save_on_top = False
698 paginator = Paginator
699 preserve_filters = True
700 show_facets = ShowFacets.ALLOW
701 inlines = ()
702
703 # Custom templates (designed to be over-ridden in subclasses)
704 add_form_template = None
705 change_form_template = None
706 change_list_template = None
707 delete_confirmation_max_display = None
708 delete_confirmation_template = None
709 delete_selected_confirmation_template = None
710 object_history_template = None
711 popup_response_template = None
712
713 # Actions
714 actions = ()
715 action_form = helpers.ActionForm
716 actions_on_top = True
717 actions_on_bottom = False
718 actions_selection_counter = True
719 checks_class = ModelAdminChecks
720
721 def __init_subclass__(cls, **kwargs) -> None:
722 super().__init_subclass__(**kwargs)
723 if cls.__dict__.get("list_select_related") is True:
724 # RemovedInDjango70Warning: when the deprecation ends, raise a
725 # ValueError.
726 warnings.warn(
727 "Setting ModelAdmin.list_select_related to True is deprecated. "
728 "Use False or a list or tuple of fields to fetch instead.",
729 RemovedInDjango70Warning,
730 skip_file_prefixes=django_file_prefixes(),
731 )
732
733 def __init__(self, model, admin_site):
734 self.model = model
735 self.opts = model._meta
736 self.admin_site = admin_site
737 super().__init__()
738
739 def __str__(self):

Calls

no outgoing calls