... connection() and connection arguments Replacing fail_silently Migrating custom email backends Replacing auth_user and auth_password Updating AdminEmailHandler email_backend Ignoring transient failures in error reporting バージョン 6.1 で非推奨: The f ... ollowing settings and functions will be removed in Django 2028: EMAIL_BACKEND , EMAIL_FILE_PATH , EMAIL_HOST , EMAIL_HOST_PASSWORD , EMAIL_HOST_USER , EMAIL_PORT , EMAIL_SSL_CERTFILE , EMAIL_SSL_KEYFILE , EMAIL_TIMEOUT , EMAIL_USE_SSL , EMAIL_USE_TL ... ument to send_mail() , send_mass_mail() , mail_admins() , mail_managers() , and EmailMessage.send() The auth_user and auth_password arguments to send_mail() and send_mass_mail() The email_backend argument to AdminEmailHandler Migrating settings Often ... ... r を持たない場合、以下の定義を使用してください。 from django.db import models class Manufacturer ( models . Model ): # ... pass class Car ( models . Model ): manufacturer = models . ForeignKey ( Manufacturer , on_delete = models . CASCADE ) # ... 再帰 ... 複数の topping を持つ)場合、以下のように表現できます。 from django.db import models class Topping ( models . Model ): # ... pass class Pizza ( models . Model ): # ... toppings = models . ManyToManyField ( Topping ) ForeignKey と同様に、 再帰的なリレー ... 名はPythonの予約語にはできません。Pythonの構文エラーになるからです。たとえば次のようなものです: class Example(models.Model): pass = models.IntegerField() # 'pass' is a reserved word! フィールド名には連続したアンダースコアを2つ以上含めることはできません ... ... ができます。たとえば: from django.conf import settings def my_view ( request ): if settings . SITE_ID == 3 : # Do something. pass else : # Do something else. pass It's fragile to hardcode the site IDs like that, in case they change. The cleaner way of ... ef my_view ( request ): current_site = get_current_site ( request ) if current_site . domain == "foo.com" : # Do something pass else : # Do something else. pass これには、サイトフレームワークがインストールされているかどうかを確認するという利点もありま ... _without_request (): current_site = Site . objects . get_current () if current_site . domain == "foo.com" : # Do something pass else : # Do something else. pass 表示用の現在のドメインを取得する LJWorld.com と Lawrence.com はどちらも、ニュースが発生し ... ... ostgres_settings ). The remainder of this documentation shows commands for running tests without tox , however, any option passed to runtests.py can also be passed to tox by prefixing the argument list with -- , as above. Tox also respects the DJANGO ... cted_failures on each backend). To run the tests with different settings, ensure that the module is on your PYTHONPATH and pass the module with --settings . The DATABASES setting in any test settings module needs to define two databases: A default da ... ount for the database. That user needs permission to execute CREATE DATABASE so that the test database can be created. The PASSWORD option needs to provide the password for the USER that has been specified. Test databases get their names by prependin ... ... はメールサーバーへの接続方法をいくつか設定する必要があります。最低限 EMAIL_HOST と、おそらく EMAIL_HOST_USER と EMAIL_HOST_PASSWORD を指定する必要がありますが、メールサーバーの設定によっては他の設定も必要かもしれません。メール関連の設定の一覧は Djang ... tors.debug import sensitive_variables @sensitive_variables ( "user" , "pw" , "cc" ) def process_info ( user ): pw = user . pass_word cc = user . credit_card_number name = user . name ... 上記の例では、 user 、 pw 、 cc の値は非表示になり、エラーレポー ... st_parameters decorator: from django.views.decorators.debug import sensitive_post_parameters @sensitive_post_parameters ( "pass_word" , "credit_card_number" ) def record_user_profile ( request ): UserProfile . create ( user = request . user , passwor ... ... sult_count to control whether or not the full count of objects should be displayed on a filtered admin page. The AdminSite.password_change() method now has an extra_context parameter. You can now control who may login to the admin site by overriding ... 縮するために、認証バックエンドが has_perm() および has_module_perms() で PermissionDenied を発生させられるようになりました。 PasswordResetForm now has a method send_mail() that can be overridden to customize the mail to be sent. The max_length of Permi ... tabase migration. USERNAME_FIELD and REQUIRED_FIELDS now supports ForeignKey s. The default iteration count for the PBKDF2 password hasher has been increased by 33%. This backwards compatible change will not affect users who have subclassed django.co ... ... # Operations are usually instantiated with arguments in migration # files. Store the values of them on self for later use. pass def state_forwards ( self , app_label , state ): # The Operation should take the 'state' parameter (an instance of # djang ... o.db.migrations.state.ProjectState) and mutate it to match # any schema changes that have occurred. pass def database_forwards ( self , app_label , schema_editor , from_state , to_state ): # The Operation should use schema_edit ... or to apply any changes it # wants to make to the database. pass def database_backwards ( self , app_label , schema_editor , from_state , to_state ): # If reversible is True, this is call ... ... / $ ./tests/runtests.py ...\> tests\runtests.py See Running the unit tests for more information. While tests will all pass in CI, they may not on every person's local environment. For example, the test suite is only guaranteed to pass on the lat ... ... ye out for syntax that is incompatible with older but still supported versions of Python. Run the tests and make sure they pass. Where possible and relevant, try them out on a database other than SQLite. Leave comments and feedback! Keep old patches ... be true, that means you have the extra-important job of writing the very first tests for that feature, not that you get a pass from writing tests altogether. Be patient あなたのチケットやパッチが迅速にレビューされることは、必ずしも容易ではありません ... ... dlers as weak references by default, so if your handler is a local function, it may be garbage collected. To prevent this, pass weak=False when you call the signal's connect() . 注釈 モデルシグナルの sender モデルは、レシーバを接続する際にその完全なア ... Pizza が複数の Topping オブジェクトを持てるとしたら、次のようにモデル化されます。 class Topping ( models . Model ): # ... pass class Pizza ( models . Model ): # ... toppings = models . ManyToManyField ( Topping ) このようにハンドラーを接続した場合: ... from django.db.models.signals import m2m_changed def toppings_changed ( sender , ** kwargs ): # Do something pass m2m_changed . connect ( toppings_changed , sender = Pizza . toppings . through ) そして、次のようにした場合: >>> p = Pizza ... 2026年10月08日