... 加したり、特定のモジュールをプリロードしたりできます。そのためには、 django.core.management.commands.shell.Command のサブクラスを作成し、既存の shell 管理コマンドをオーバーライドする新しい管理コマンドを作成します。詳細につい ... ケーションで利用可能なオブジェクトまたはモジュールのインポートパスのシーケンスを返す必要があります。例えば: polls/management/commands/shell.py from django.core.management.commands import shell class Command ( shell . Command ): def get_auto_imports ( self ... ... rsion is 3.0 or later. The PostGIS 2 CREATE EXTENSION postgis and the SpatiaLite SELECT InitSpatialMetaData initialization commands are now automatically run by migrate . The GDAL interface now supports retrieving properties of raster (image) data file . ... base connections are now always closed after a management command called from the command line has finished doing its job. Commands from alternate package formats like eggs are now also discovered. The new dumpdata --output option allows specifying a fil ... Meta.unique_together . It is also able to introspect AutoField for MySQL and PostgreSQL databases. When calling management commands with options using call_command() , the option name can match the command line option name (without the initial dashes) or ... ... the affected column, so they are not always visible. The effect of this change is that running manage.py reset and similar commands against an existing database may generate SQL with the new form of constraint name, while the database itself contains con ... y A few of the options to manage.py have changed with the addition of fixture support: There are new dumpdata and loaddata commands which, as you might expect, will dump and load data to/from the database. These commands can operate against any of Django ... ... ions in the database. To assist with testing, call_command() now accepts a command object as the first argument. The shell command supports tab completion on systems using libedit , e.g. macOS. The inspectdb command lets you choose what tables should be ... s. Added support for non-atomic migrations by setting the atomic attribute on a Migration . The migrate and makemigrations commands now check for a consistent migration history . If they find some unapplied dependencies of an applied migration, Inconsist ... An addition in django.setup() allows URL resolving that happens outside of the request/response cycle (e.g. in management commands and standalone scripts) to take FORCE_SCRIPT_NAME into account when it is set. バリデータ URLValidator now limits the leng ... ... ay that clashed with a reverse field on the model ( #25299 ). Fixed autocompletion for options of non- argparse management commands ( #25372 ). Alphabetized ordering of imports in from django.db import migrations, models statement in newly created migrat ... ... ル で作成した polls アプリケーションに独自の closepoll コマンドを追加します。 独自のコマンドを追加するためには、 management/commands ディレクトリをアプリケーションに追加してください。Djangoは、そのディレクトリ内のアンダーバーで始まらないPythonモジュールす ... べてを manage.py コマンドに登録します。例えば: polls/ __init__.py models.py management/ __init__.py commands/ __init__.py _private.py closepoll.py tests.py views.py この例では、 closepoll コマンドは polls アプリケーションを INSTALL ... ケジューラ管理パネルから定期的に実行されるスクリプトを処理する場合に特に有用です。 コマンドを実装するには、 polls/management/commands/closepoll.py を以下のように編集してください: from django.core.management.base import BaseCommand , CommandError from polls ... ... cleaned up when switching to the new manage.py . Custom project and app templates The startapp and startproject management commands now have a --template option for specifying a path or URL to a custom app or project template. For example, Django will us ... ngoTestRunner and overriding its teardown_databases() method. Output of manage.py help manage.py help now groups available commands by application. If you depended on the output of this command -- if you parsed it, for example -- then you'll need to upda ... te your code. To get a list of all available management commands in a script, use manage.py help --commands instead. extends template tag Previously, the extends tag used a buggy method o ... ... ad ordering set (#21405). Removed mention of a feature in the --locale / -l option of the makemessages and compilemessages commands that never worked as promised: Support of multiple locale names separated by commas. It's still possible to specify multip ... ... sts are logged to the console, including requests for static files or favicon.ico that used to be filtered out. Management commands can now produce syntax colored output under Windows if the ANSICON third-party tool is installed and active. collectstatic ... configuration class. Django will enforce these requirements as of version 1.9, after a deprecation period. Subclassing AppCommand Subclasses of AppCommand must now implement a handle_app_config() method instead of handle_app() . This method receives an ... nstalled argument of get_model and get_models no longer exists, nor does the seed_cache argument of get_model . Management commands and order of INSTALLED_APPS When several applications provide management commands with the same name, Django loads the com ... ... sites.AdminSite.display_login_form' has been removed in favor of a new login_form attribute. reset and sqlreset management commands Those commands have been deprecated. The flush and sqlflush commands can be used to delete everything. You can also use AL ... 2026年10月08日