... の基本を示した最小限のテンプレートです。各要素については、この文書の後半で説明します。 {% extends "base_generic.html" %} {% block title %}{{ section.title }}{% endblock %} {% block content %} < h1 > {{ section.title }} </ h1 > {% for story in story_lis ... } " > {{ story.headline | upper }} </ a > </ h2 > < p > {{ story.tease | truncatewords :"100" }} </ p > {% endfor %} {% endblock %} 設計思想 なぜ、(ZopeのTALのような) XMLベースのテンプレートではなく、テキストベースのテンプレートを使うのか?それは、Djan ... ィルタは文字列を返すので、フィルタを使った数学的な比較は通常は期待通りにならないことに注意してください。 length は例外です。 block と extends テンプレートの "定型文" を削減する強力な方法である template inheritance (下記参照)を設定します。 繰り返します ... ... w rules in Django template code. {% extends %} should be the first non-comment line. Do this: {% extends "base.html" %} {% block content %} < h1 class = "font-semibold text-xl" > {{ pages.title }} </ h1 > {% endblock content %} Or this: {# This is a c ... omment #} {% extends "base.html" %} {% block content %} < h1 class = "font-semibold text-xl" > {{ pages.title }} </ h1 > {% endblock content %} Don't do this: {% load ... i18n %} {% extends "base.html" %} {% block content %} < h1 class = "font-semibold text-xl" > {{ pages.title }} </ h1 > {% endblock content %} Put exactly one space b ... ... _ready ブロックを拡張し、イベントリスナーのコードを追加します: {% extends 'admin/change_form.html' %} {% load static %} {% block admin_change_form_document_ready %} {{ block .super }} < script src = " {% static 'app/formset_handlers.js' %} " ></ scrip ... t > {% endblock %} app/static/app/formset_handlers.js document . addEventListener ( 'formset:added' , ( event ) => { if ( event . detail . ... ge_form_document_ready ブロックには、変更フォーム内でのさまざまな操作を処理するための JavaScript コードが含まれており、 {{ block.super }} は、それらもレンダリングする必要があるために追加されています。 バージョン4.1より前のDjangoをサポートする もしイベ ... ... I:%M %p" as the_time %} < p > The time is {{ the_time }} . </ p > シンプル・ブロック・タグ django.template.Library. simple_block_tag () When a section of rendered template needs to be passed into a custom tag, Django provides the simple_block_tag help ... ます: from django import template from myapp.charts import render_chart register = template . Library () @register . simple_block_tag def chart ( content ): return render_chart ( source = content ) content 引数には、 {% chart %} と {% endchart %} タグの ... me} (たとえば endchart )で閉じます。この閉じタグの名前は、 end_name パラメータでカスタマイズできます: @register . simple_block_tag ( end_name = "endofchart" ) def chart ( content ): return render_chart ( source = content ) この場合、テンプレートの定 ... ... site.html テンプレートにカスタムロゴを追加できます: templates/admin/base_site.html {% extends "admin/base_site.html" %} {% block branding %} < img src = "link/to/logo.png" alt = "logo" > {{ block .super }} {% endblock %} 備考: この例では、 templates/a ... れはオーバーライドされるテンプレートと同じです。 このテンプレートは branding ブロックだけを置き換え、カスタムロゴを追加し、 block.super を使って以前のコンテンツを保持します。 残りのテンプレートは admin/base_site.html からそのまま継承されます。 このテク ... するときに、すでにロードされているオーバーライドテンプレート ( templates/admin/base_site.html ) を考慮しないので動作します。 block.super と組み合わせることで、小さなカスタマイズを行うための強力なテクニックとなります。 ... ... します。 Documentation quality checks Several checks help maintain Django's documentation quality, including spelling , code block formatting , and documentation style . These checks are run automatically in CI and must pass before documentation changes ... と確信できる場合のみ、その単語を docs/spelling_wordlist に追加してください(リストはアルファベット順にしてください)。 Code block format check All Python code blocks should be formatted using the blacken-docs auto-formatter. This is automatically run b ... ke black ...\> make.bat black The formatter will report any issues by printing them to the terminal and will reformat code blocks where possible. Documentation lint check Django's documentation is checked for reStructuredText style and formal issues u ... ... たとしましょう。テンプレートは以下のように書かれています: news/templates/news/year_archive.html {% extends "base.html" %} {% block title %} Articles for {{ year }}{% endblock %} {% block content %} < h1 > Articles for {{ year }} </ h1 > {% for article i ... {{ article.reporter.full_name }} </ p > < p > Published {{ article.pub_date | date :"F j, Y" }} </ p > {% endfor %} {% endblock %} 変数は二重の波括弧で囲まれています。 {{ article.headline }} は、「article の headline という属性の出力」を表しています。 ... で、 静的ファイルの配信 を含む例をあげます: templates/base.html {% load static %} < html lang = "en" > < head > < title > {% block title %}{% endblock %} </ title > </ head > < body > < img src = " {% static 'images/sitelogo.png' %} " alt = "Logo" > {% ... ... new no_key parameter for QuerySet.select_for_update() , supported on PostgreSQL, allows acquiring weaker locks that don't block the creation of rows that reference locked rows through a foreign key. When() expression now allows using the condition ar ... ーム(Transform)を参照できる for details. The new durable argument for atomic() guarantees that changes made in the atomic block will be committed if the block exits without errors. A nested atomic block marked as durable will raise a RuntimeError . A ... he undocumented django.core.files.locks.lock() function now returns False if the file cannot be locked, instead of raising BlockingIOError . The password reset mechanism now invalidates tokens when the user email is changed. makemessages command no lo ... ... plate.html` これらはすべて、 :role:`link text <link>` の形式でカスタムリンクテキストをサポートしています。たとえば、 :tag:`block <built_in-block>` のように記述します。 モデルのリファレンス admindocs ページの models セクションでは、ユーザーがアクセス可 ... ... min/templates/admin/change_list.html template added in Django 6.0 that could be problematic when overriding the pagination block ( #37029 ). Fixed a bug in Django 6.0 where deprecation warnings incorrectly skipped lines from third-party packages prefi ... 2026年10月08日