... 最後に、アプリケーションのモデルのうちどれが管理インターフェースで編集可能であるべきかを決定します。それらのモデルごとに、 ModelAdmin に記述されているように、管理サイトに登録します。 他のトピック 管理アクション ModelAdmin リストフィルタ Django admin ドキュ ... admin highlighted on the Community Ecosystem page. The Django Packages Admin interface grid has even more options for you! ModelAdmin のオブジェクト class ModelAdmin [ソース] ModelAdmin クラスは、admin インターフェース内でモデルを表現する方法です。通常、ア ... プリケーション内の admin.py に記述されます。 ModelAdmin の例を見てみましょう: from django.contrib import admin from myapp.models import Author class AuthorAdmin ( admin . ModelAd ... ... を使用します。使用したモデルの delete() メソッドが呼ばれないことは重要な注意点です。 この動作をオーバーライドしたい場合は、 ModelAdmin.delete_queryset() をオーバーライドするか、選択された各アイテムに対して Model.delete() を呼び出すなど、お好みの方法で削除を ... アクションがトリガーされたときに呼び出される関数を書く必要があります。アクション関数は3つの引数を取る通常の関数です: 現在の ModelAdmin 現在のリクエストを表す HttpRequest ユーザーが選択したオブジェクトのセットを含む QuerySet 。 publish-these-articles 関数は ... ModelAdmin やリクエストオブジェクトを必要としませんが、クエリセットを使用します: def make_published ( modeladmin , request , queryset ): queryset . update ( status = "p" ) 注釈 最高のパフォーマンスを得るために、クエリセットの update メ ... ... ュール) action_flag (LogEntry の属性) action_time (LogEntry の属性) ActionLocation (django.contrib.admin のクラス) actions (ModelAdmin の属性) actions_on_bottom (ModelAdmin の属性) actions_on_top (ModelAdmin の属性) actions_selection_counter (ModelAdmin の属 ... chemaEditor のメソッド) add_error() (Form のメソッド) add_field() (BaseDatabaseSchemaEditor のメソッド) add_form_template (ModelAdmin の属性) add_index() (BaseDatabaseSchemaEditor のメソッド) add_item() (SyndicationFeed のメソッド) add_item_elements() (Syn ... se のメソッド) add_root_elements() (SyndicationFeed のメソッド) add_stylesheets() (SyndicationFeed のメソッド) add_view() (ModelAdmin のメソッド) AddConstraint (django.db.migrations.operations のクラス) AddConstraintNotValid (django.contrib.postgres.operat ... ... teTimeField , IntegerField , ForeignKey または ManyToManyField のいずれかでなければなりません: class PersonAdmin ( admin . ModelAdmin ): list_filter = [ "is_staff" , "company" ] list_filter 内のフィールド名は __ ルックアップを使って関係先を参照できます。た ... t . filter ( birthday__gte = date ( 1990 , 1 , 1 ), birthday__lte = date ( 1999 , 12 , 31 ), ) class PersonAdmin ( admin . ModelAdmin ): list_filter = [ DecadeBornListFilter ] 注釈 利便性のため、 HttpRequest オブジェクトが lookups と queryset メソッドに渡さ ... super () . queryset ( request , queryset ) たとえば利用可能なデータに基づくルックアップを行いたい場合などに便利なように、 ModelAdmin オブジェクトは lookups メソッドに渡されます。 class AdvancedDecadeBornListFilter ( DecadeBornListFilter ): def lookups ( s ... ... e style customizations. The admin's search fields can now be customized per-request thanks to the new django.contrib.admin.ModelAdmin.get_search_fields() method. The ModelAdmin.get_fields() method may be overridden to customize the value of ModelAdmin.fiel ... ds . In addition to the existing admin.site.register syntax, you can use the new register() decorator to register a ModelAdmin . You may specify ModelAdmin.list_display_links = None to disable links on the change list page grid. You may now specify ... min.view_on_site to control whether or not to display the "View on site" link. You can specify a descending ordering for a ModelAdmin.list_display value by prefixing the admin_order_field value with a hyphen. The ModelAdmin.get_changeform_initial_data() me ... ... いパーミッションは migrate 実行時に自動的に作成されます。 This allows giving users read-only access to models in the admin. ModelAdmin.has_view_permission() is new. The implementation is backwards compatible in that there isn't a need to assign the "view" p ... mission to edit objects. There are a couple of backwards incompatible considerations . マイナーな機能 django.contrib.admin ModelAdmin.search_fields now accepts any lookup such as field__exact . jQuery のバージョンが 2.2.3 から 3.3.1 にアップグレードされまし ... た。 The new ModelAdmin.delete_queryset() method allows customizing the deletion process of the "delete selected objects" action. You can now over ... ... rguments will raise TypeError . QuerySet.select_related() will raise TypeError if passed True rather than AttributeError . ModelAdmin will raise ValueError if subclassed with its list_select_related attribute set to True . ModelAdmin will raise ValueError ... if its get_list_select_related() method returns True . Support for overriding ModelAdmin.get_actions() without the new action_location parameter will be removed. Support for unpacking or indexing the dictionary ... values of the ModelAdmin.get_actions() return value will be removed. Use Action attributes instead. Support for overriding ModelAdmin.get_action_ch ... ... ... change" but not "add" permission can create objects for ModelAdmin 's with save_as=True If a ModelAdmin uses save_as=True (not the default), the admin provides an option when editing object ... BLE_NUMBER compile-time limit to over 2000, such as Debian ( #26063 ). Fixed a crash when using a reverse OneToOneField in ModelAdmin.readonly_fields ( #26060 ). Fixed a crash when calling the migrate command in a test case with the available_apps attribut ... ... lectMultiple widget now uses <optgroup> s to preserve named groups (e.g. choices=[("Group", [("1", "Item")]), ...] ). When ModelAdmin.list_select_related is False (the default), the change list now selects only the foreign key fields specified in ModelAdmi ... able related fields is deprecated. Specify the related fields to fetch instead, or use the FETCH_PEERS fetch mode. Setting ModelAdmin.list_select_related to True and returning True from ModelAdmin.get_list_select_related() are deprecated. Specify the relat ... l change from "sha1" to "sha256" in Django 2028. Pass an explicit algorithm to silence the deprecation warning. Overriding ModelAdmin.get_actions() without the new action_location parameter is deprecated. Unpacking or indexing the dictionary values of the ... 2026年10月08日