... g file. We recommend using a text editor with EditorConfig support to avoid indentation and whitespace issues. Most of the JavaScript files use 4 spaces for indentation, but there are some exceptions. When naming variables, use camelCase instead of undersc ... ore_case . Different JavaScript files sometimes use a different code style. Please try to conform to the code style of each file. Use the Biome code linte ... ome plugin in your text editor. Where possible, write code that will work even if the page structure is later changed with JavaScript. For instance, when binding a click handler, use $('body').on('click', selector, func) instead of $(selector).click(func) ... ... ( "Welcome {name} " ) . format ( name = name ) # Bad _ ( f "Welcome { name } " ) # f-string evaluated before translation. JavaScript のテンプレート文字列を使うには、 gettext のバージョン 0.21 以降が必要です。 翻訳者へのコメント 翻訳可能な文字列についてのヒ ... E|language_bidi }} (False) {{ LANGUAGE_CODE|language_name_translated }} ("německy", when active language is Czech) 国際化: JavaScript コード内 JavaScript に対する翻訳には、いくつか問題があります: JavaScript コードは gettext 実行にアクセスできません。 JavaS ... cript コードは .po や .mo ファイルにアクセスできません; サーバーによって配布される必要があります。 JavaScript 用の翻訳カタログはできる限り小さくなければなりません。 Django には、これらの問題に対する総合的な解決策が用意されています: ... ... 'formset:removed' , ( event ) => { // Row removed }); 注意点が2つあります: もし admin/change_form.html を継承しているなら、JavaScript コードはテンプレートブロック内に配置する必要があります。そうしないと、最終的な HTML にレンダリングされません。 Django の a ... dmin_change_form_document_ready ブロックには、変更フォーム内でのさまざまな操作を処理するための JavaScript コードが含まれており、 {{ block.super }} は、それらもレンダリングする必要があるために追加されています。 バージョン4.1より前 ... ーが古いバージョンのDjangoをサポートする必要がある場合は、jQueryを使用してイベントリスナーを登録する必要があります。jQueryはJavaScriptイベントを処理しますが、その逆は成り立ちません。 event.detail.formsetName の存在をチェックし、次のように古いリスナーのシグネ ... ... な CSS と JavaScript の組み合わせは、そのページに使用されるウィジェットによって異なります。 ここでアセット定義の出番です。Django では異なるファ ... て、DateFields を描画するのにカレンダーを使いたい場合、独自の Calendar ウィジェットを定義したとき、このウィジェットは CSS や JavaScript と紐付けることができます。フォーム上でこの Calendar ウィジェットを使用するとき、Django は必要な CSS および JavaScript のフ ... ったら、ご自分の アプリケーションで自由に使ってください!これらは全て django.contrib.admin.widgets に格納されています。 どの JavaScript ツールキットを使えばいいの? 多くの JavaScript ツールキットが存在し、その多くにはウィジェット (カレンダ ーウィジェットなど) ... ... ks for these redirects (namely django.utils.http.is_safe_url() ) didn't check if the scheme is http(s) and as such allowed javascript:... URLs to be entered. If a developer relied on is_safe_url() to provide safe redirect targets and put such a URL into a ... doesn't affect Django currently, since we only put this URL into the Location response header and browsers seem to ignore JavaScript there. バグ修正 Fixed an obscure bug with the override_settings() decorator. If you hit an AttributeError: 'Settings' obje ... ... Windows users should use: ...\> set DJANGO_SETTINGS_MODULE = my_postgres_settings ...\> tox -e py312-postgres Running the JavaScript tests Django includes a set of JavaScript unit tests for functions in certain contrib apps. The JavaScript tests aren't ru ... efault using tox because they require Node.js to be installed and aren't necessary for the majority of patches. To run the JavaScript tests using tox : / $ tox -e javascript ...\> tox -e javascript This command runs npm install to ensure test requireme ... ... nonce or hash), without needing 'unsafe-inline' . UNSAFE_EVAL Represents 'unsafe-eval' . Allows use of eval() and similar JavaScript functions. Strongly discouraged. UNSAFE_HASHES Represents 'unsafe-hashes' . Allows inline event handlers and some javascri ... cy rule. Requires CSP Level 3+. UNSAFE_INLINE Represents 'unsafe-inline' . Allows execution of inline scripts, styles, and javascript: URLs. Generally discouraged, especially for scripts. WASM_UNSAFE_EVAL Represents 'wasm-unsafe-eval' . Permits compilation ... le> elements, include the nonce directly using the context variable: < script nonce = " {{ csp_nonce }} " > // This inline JavaScript will be allowed. </ script > For external <script src="..."> and <link rel="stylesheet"> elements, use the csp_nonce_attr ... ... ks for these redirects (namely django.utils.http.is_safe_url() ) didn't check if the scheme is http(s) and as such allowed javascript:... URLs to be entered. If a developer relied on is_safe_url() to provide safe redirect targets and put such a URL into a ... doesn't affect Django currently, since we only put this URL into the Location response header and browsers seem to ignore JavaScript there. XSS vulnerability in django.contrib.admin If a URLField is used in Django 1.5, it displays the current value of the ... ... ... .urls.handler403 . See the documentation about the 403 (HTTP Forbidden) view for more information. makemessages コマンドが JavaScript ファイルから翻訳可能な文字列を抽出するために、新しくてより正確な字句解析ライブラリ JsLex を使用するようになりました。 The ... rnal error page served when DEBUG is True is now sent to the client when Django detects that the request has originated in JavaScript code. ( is_ajax() is used for this.) Like its HTML counterpart, it contains a collection of different pieces of informatio ... n about the state of the application. This should make it easier to read when debugging interaction with client-side JavaScript. Added the makemessages --no-location option. Changed the locmem cache backend to use pickle.HIGHEST_PROTOCOL for better c ... 2026年10月08日