... mport CSP SECURE_CSP = { "default-src" : [ CSP . SELF ], # Allow self-hosted scripts and script tags with matching `nonce` attr. "script-src" : [ CSP . SELF , CSP . NONCE ], # Example of the less secure 'unsafe-inline' option. "style-src" : [ CSP . S ... cript will be allowed. </ script > For external <script src="..."> and <link rel="stylesheet"> elements, use the csp_nonce_attr template tag: < script src = "/path/to/script.js" {% csp_nonce_attr %} ></ script > < link rel = "stylesheet" href = "/pat ... h/to/style.css" {% csp_nonce_attr %} > To render a Media object's assets with the nonce applied to each element, pass the object to the csp_nonce_attr tag: ... ... processor needs to be enabled. It adds a csp_nonce variable to the template context. Changed in Django 6.1: The csp_nonce_attr template tag was added, including support for rendering Media objects. For inline <script> and <style> elements, include t ... cript will be allowed. </ script > For external <script src="..."> and <link rel="stylesheet"> elements, use the csp_nonce_attr template tag: < script src = "/path/to/script.js" {% csp_nonce_attr %} ></ script > < link rel = "stylesheet" href = "/pat ... h/to/style.css" {% csp_nonce_attr %} > To render a Media object's assets with the nonce applied, pass the object to the csp_nonce_attr template tag: {% csp_ ... ... , now only allows accessing the date/time formatting settings. バグ修正 Fixed a data loss possibility with Prefetch if to_attr is set to a ManyToManyField ( #25693 ). ... ... Prefetch ( "restaurants" , queryset = Restaurant . objects . select_related ( "best_pizza" )) ... ) また、オプションの to_attr で、事前読み込みの結果を独自の属性に割り当てることもできます。結果はリストに直接格納されます。 これにより、異なる QuerySet ... Pizza . objects . filter ( vegetarian = True ) >>> Restaurant . objects . prefetch_related ( ... Prefetch ( "pizzas" , to_attr = "menu" ), ... Prefetch ( "pizzas" , queryset = vegetarian_pizzas , to_attr = "vegetarian_menu" ), ... ) 独自の to_attr で ... etarian = True ) >>> Restaurant . objects . prefetch_related ( ... Prefetch ( "pizzas" , queryset = vegetarian_pizzas , to_attr = "vegetarian_menu" ), ... "vegetarian_menu__toppings" , ... ) to_attr の使用は、関係するマネージャのキャッシュにフィルタし ... ... on with South migrations in the migrations directory to fail ( #25618 ). Fixed a data loss possibility with Prefetch if to_attr is set to a ManyToManyField ( #25693 ). Fixed a regression in 1.8 by making gettext() once again return UTF-8 bytestrings ... ... このタグは CSRF の防止のために使用します。詳細は クロスサイトリクエストフォージェリ (CSRF) を参照してください。. csp_nonce_attr New in Django 6.1. When called without arguments, renders a nonce="<value>" HTML attribute when the csp() context processo ... link> elements to allow them under a nonce-based Content Security Policy: < script src = "/path/to/script.js" {% csp_nonce_attr %} ></ script > < link rel = "stylesheet" href = "/path/to/style.css" {% csp_nonce_attr %} > When called with a Media obje ... ct as the argument, renders its assets with the CSP nonce applied to each <script> and <link> element: {% csp_nonce_attr form.media %} In both forms, if the context processor is not configured, assets are rendered without a nonce attribute. Se ... ... re. Remember that if you want your test user to have a password, you can't set the user's password by setting the password attribute directly -- you must use the set_password() function to store a correctly hashed password. Alternatively, you can use ... 集した設定 でテストを実行する機能。 Access to the synchronous and asynchronous test clients via the client and async_client attributes. データベースクエリを作る手薄との場合、サブクラス TransactionTestCase や TestCase を使用してください。 SimpleTestCas ... SQL) で実行される場合、各テストの前に setUpTestData() が呼ばれ、高速化のメリットはなくなります。 Objects assigned to class attributes in setUpTestData() must support creating deep copies with copy.deepcopy() in order to isolate them from alterations ... ... "django" : ( "https://docs.djangoproject.com/en/stable/" , None , ), } これを設定すると、 Django ドキュメントと同様に、 " :attr:`django.test.TransactionTestCase.databases` " などの特定のエントリに相互リンクできるようになります。 build パッケージがイン ... ... ぞれスタックレイアウトと表形式のレイアウトを持っています。 GenericPrefetch() class GenericPrefetch ( lookup , querysets , to_attr = None ) [ソース] このルックアップは Prefetch() に類似しており、 GenericForeignKey 専用に使用されるべきです。 querysets 引 ... ... ash index type. django.contrib.sessions SessionBase now supports boolean evaluation via __bool__() . CSP The new csp_nonce_attr template tag renders the CSP nonce attribute on <script> and <link> elements, or renders a Media object's assets with the ... ddleware is enabled with CSP.NONCE in a CSP policy but django.template.context_processors.csp is not configured. CSP nonce attributes are now added on <script> , <style> , and <link> elements in admin templates and all built-in templates when the csp ... fined but does not include a 'default' entry. フォーム The new asset object Stylesheet is available for adding custom HTML-attributes to stylesheet links in form media. See paths as objects for more details. The new constant django.db.models.fields.B ... 2026年10月08日