... わりに使います。 Django はその Python モジュールをロードして、 urlpatterns という名前の変数を探します。この変数の値は django.urls.path() または django.urls.re_path() インスタンスの sequence でなければなりません。 Django は URL パターンを順に調べて、 pa ... 置引数として提供されます。 指定された URL パス表現でマッチした名前付き部分からはキーワード引数が作られます。ただし、 django.urls.path() や django.urls.re_path() に kwargs オプション引数が指定されていた場合は、その中の引数で上書きされます。 もし、 URL ... ーハンドリングビューを呼び出します。下の Error handling を見てください。 カスタマイズ例 URLconf のサンプルです。 from django.urls import path from . import views urlpatterns = [ path ( "articles/2003/" , views . special_case_2003 ), path ( "articles/<i ... ... ようにしましょう。 startproject が何を作成したかをみてみましょう: djangotutorial/ manage.py mysite/ __init__.py settings.py urls.py asgi.py wsgi.py ファイルはそれぞれ以下のような役割を持っています: manage.py : Django プロジェクトに対する様々な操作を行 ... このディレクトリの名前は、内部のモジュールやパッケージをインポートするために使用するPythonパッケージ名になります(例: mysite.urls )。 mysite/__init__.py : このディレクトリが Python パッケージであることを Python に知らせるための空のファイルです。Python ... ttings.py : Settings/configuration for this Django project. Djangoの設定 will tell you all about how settings work. mysite/urls.py : Django プロジェクトの URL 宣言、いうなれば Django サイトにおける「目次」に相当します。詳しくは URL ディスパッチャ を参 ... ... 記の通り Article モデルが定義されていると仮定します: from django.db import models from django.urls import reverse class Article ( models . Model ): title = models . CharField ( max_length = 200 ) pub_date = models . DateF ... ルトですが、 date_list_period 属性を用いた月や日に変更できます。これは、すべてのサブクラスのビューに適用されます。 例 myapp/urls.py : from django.urls import path from django.views.generic.dates import ArchiveIndexView from myapp.models import Article ... View ): queryset = Article . objects . all () date_field = "pub_date" make_object_list = True allow_future = True 例 myapp/urls.py : from django.urls import path from myapp.views import ArticleYearArchiveView urlpatterns = [ path ( "<int:year>/" , Ar ... ... he user to an "on success" URL. The security checks for these redirects (namely django.utils.http.is_safe_url() ) accepted URLs with leading control characters and so considered URLs like \x08javascript:... safe. This issue doesn't affect Django curr ... put this URL into the Location response header and browsers seem to ignore JavaScript there. Browsers we tested also treat URLs prefixed with control characters such as %08//example.com as relative paths so redirection to an unsafe target isn't a pro ... ... the project are imported or referenced using the project name prefix (e.g. myproject.settings , ROOT_URLCONF = "myproject.urls" , etc.), the new manage.py will need to be moved one directory up, so it is outside the project package rather than adjac ... ent to settings.py and urls.py . For instance, with the following layout: manage.py mysite/ __init__.py settings.py urls.py myapp/ __init__.py models. ... py You could import mysite.settings , mysite.urls , and mysite.myapp , but not settings , urls , or myapp as top-level modules. Anything imported as a top-level module can ... ... sts with a Content-Disposition header have also been removed as they were found to have similar issues. Malformed redirect URLs from user input not correctly validated The validation for redirects did not correctly validate some malformed URLs, which ... he security checks for these redirects (namely django.utils.http.is_safe_url() ) did not correctly validate some malformed URLs, such as http:\\\\\\djangoproject.com , which are accepted by some browsers with more liberal URL parsing. To remedy this, ... the validation in is_safe_url() has been tightened to be able to handle and correctly validate these malformed URLs. ... ... sts with a Content-Disposition header have also been removed as they were found to have similar issues. Malformed redirect URLs from user input not correctly validated The validation for redirects did not correctly validate some malformed URLs, which ... he security checks for these redirects (namely django.utils.http.is_safe_url() ) did not correctly validate some malformed URLs, such as http:\\\\\\djangoproject.com , which are accepted by some browsers with more liberal URL parsing. To remedy this, ... the validation in is_safe_url() has been tightened to be able to handle and correctly validate these malformed URLs. ... ... ags() call without escaping it first, for example with escape() . Mitigated possible XSS attack via user-supplied redirect URLs Django relies on user input in some cases (e.g. django.contrib.auth.views.login() and i18n ) to redirect the user to an "o ... n success" URL. The security checks for these redirects (namely django.utils.http.is_safe_url() ) accepted URLs with leading control characters and so considered URLs like \x08javascript:... safe. This issue doesn't affect Django curr ... put this URL into the Location response header and browsers seem to ignore JavaScript there. Browsers we tested also treat URLs prefixed with control characters such as %08//example.com as relative paths so redirection to an unsafe target isn't a pro ... ... ags() call without escaping it first, for example with escape() . Mitigated possible XSS attack via user-supplied redirect URLs Django relies on user input in some cases (e.g. django.contrib.auth.views.login() and i18n ) to redirect the user to an "o ... n success" URL. The security checks for these redirects (namely django.utils.http.is_safe_url() ) accepted URLs with leading control characters and so considered URLs like \x08javascript:... safe. This issue doesn't affect Django curr ... put this URL into the Location response header and browsers seem to ignore JavaScript there. Browsers we tested also treat URLs prefixed with control characters such as %08//example.com as relative paths so redirection to an unsafe target isn't a pro ... ... ( "articles/<slug:title>/<int:section>/" , views . section , name = "article-section" ), path ( "blog/" , include ( "blog.urls" )), ... , ] route The route argument should be a string or gettext_lazy() (see URL パターンを翻訳する ) that contains a U ... します。 view view 引数は、ビュー関数、またはクラスベースビューの場合は as_view() の結果です。また、 view 引数には、 django.urls.include() を指定することもできます。 Djangoが一致するパターンを見つけると、指定されたビュー関数を呼び出し、最初の引数として ... 。 re_path() re_path ( route , view , kwargs = None , name = None ) urlpatterns に含める要素を返します。例えば: from django.urls import include , re_path urlpatterns = [ re_path ( r "^index/$" , views . index , name = "index" ), re_path ( r "^bio/(?P< ... 2026年10月08日