... Constants for Content Security Policy django.utils.dateparse Functions to parse strings to datetime objects. django.utils.decorators Functions that help with creating decorators for views. django.utils.encoding A series of helper functions to manage chara ... ezone support. django.utils.translation Internationalization support. v django.views Django's built-in views. django.views.decorators.cache django.views.decorators.common django.views.decorators.csp django.views.decorators.csrf django.views.decorators.gzip ... django.views.decorators.http django.views.decorators.vary django.views.generic.dates django.views.i18n ... ... ラス) async_client (SimpleTestCase の属性) async_client_class (SimpleTestCase の属性) async_only_middleware() (django.utils.decorators モジュール) async_to_sync() (asgiref.sync モジュール) AsyncClient (django.test のクラス) AsyncPage (django.core.paginator ... s.make_template_fragment_key() django.core.management.call_command() django.core.serializers.get_serializer() django.views.decorators.cache.cache_page() bulk_create() (django.db.models.query.QuerySet モジュール) bulk_update() (django.db.models.query.QueryS ... et モジュール) byteorder (WKBWriter の属性) C cache template tag cache_control() (django.views.decorators.cache モジュール) cache_key_prefix (backends.cached_db.SessionStore の属性) CACHE_MIDDLEWARE_ALIAS setting CACHE_MIDDLEWAR ... ... ください。 特定のHTTPメソッドのみ許可する django.views.decorators.http にあるデコレータを使用することで、リクエストメソッドに基づいてビューへのアクセスを制限できます。アクセスが制限されると ... [ソース] ビューが特定のリクエストメソッドのみを受け付けるようにするデコレータです。以下のように使います。 from django.views.decorators.http import require_http_methods @require_http_methods ([ "GET" , "POST" ]) def my_view ( request ): # I can assume now th ... トに依存しているため、 require_GET の代わりに require_safe を使用することをお勧めします。 条件付きのビュー処理 django.views.decorators.http にある以下のデコレータを使って、特定のビューのキャッシュ動作を制御できます。 condition ( etag_func = None , last_modi ... ... e follows the new rules for stateful template tags The user_passes_test() , login_required() , and permission_required() , decorators from django.contrib.auth only apply to functions and no longer work on methods. There's a simple one-line fix detailed bel ... thread safe, this leakage no longer occurs. user_passes_test , login_required and permission_required django.contrib.auth.decorators provides the decorators login_required , permission_required and user_passes_test . Previously it was possible to use thes ... e decorators both on functions (where the first argument is 'request') and on methods (where the first argument is 'self', and the seco ... ... ax-age セクションがある場合) は、 CACHE_MIDDLEWARE_SECONDS ではなく、有効期限までページがキャッシュされます。 django.views.decorators.cache のデコレータを使用すると、ビューの有効期限を簡単に設定 ( cache_control() デコレータを使用) したり、ビューのキャッシュ ... Z が True に設定されている場合、キャッシュキーには カレントタイムゾーン も含まれます。 ビューごとのキャッシュ django.views.decorators.cache. cache_page ( timeout , * , cache = None , key_prefix = None ) キャッシュフレームワークをより細かい単位で使用するには ... 、個別のビューの出力をキャッシュする方法があります。 django.views.decorators.cache は cache_page デコレーターを定義しており、これを使うとビューのレスポンスが自動的にキャッシュされるようになります。 f ... ... Cache backend ( #33361 ). Relaxed the check added in Django 4.0 to reallow use of a duck-typed HttpRequest in django.views.decorators.cache.cache_control() and never_cache() decorators ( #33350 ). Fixed a regression in Django 4.0 that caused creating bogus ... ... ヘッダを設定しないよう、ビューデコレータでミドルウェアに指示できます: from django.http import HttpResponse from django.views.decorators.clickjacking import xframe_options_exempt @xframe_options_exempt def ok_to_load_in_a_frame ( request ): return HttpRespons ... ごとに設定するために、Django は次のようなデコレータを提供しています: from django.http import HttpResponse from django.views.decorators.clickjacking import xframe_options_deny from django.views.decorators.clickjacking import xframe_options_sameorigin @xframe ... ... ッドの結果をデコレートします。これが最も簡単にできる場所は、ビューをデプロイする URLconf の中です。 from django.contrib.auth.decorators import login_required , permission_required from django.views.generic import TemplateView from .views import VoteView urlp ... し、インスタンスのメソッドのデコレーションに使えるようにできます。たとえば、次のように使用します。 from django.contrib.auth.decorators import login_required from django.utils.decorators import method_decorator from django.views.generic import TemplateView c ... ストまたはタプルを定義して、これを method_decorator() を複数回呼ぶ代わりに使用できます。以下の2つのクラスは同じになります。 decorators = [ never_cache , login_required ] @method_decorator ( decorators , name = "dispatch" ) class ProtectedView ( TemplateView ... ... mport myview urlpatterns = patterns ( "" , ( "^myview/$" , myview )) One useful application of this can be seen when using decorators; this change allows you to apply decorators to views in your URLconf . Thus, you can make a generic view require login ver ... y easily: from django.conf.urls.defaults import * from django.contrib.auth.decorators import login_required from django.views.generic.list_detail import object_list from mysite.myapp.models import MyModel inf ... ... ば、クライアントに対して、コンテンツが前回のリクエスト以降変更されていないことを伝えます。 これら 2 つの関数は django.views.decorators.http.condition デコレータのパラメータとして渡されます。このデコレータは、HTTP リクエストのヘッダがリソースのヘッダと一致す ... lished" ) . published この機能を使えば、トップページビューで変更されていないページを早期に検出できます。 from django.views.decorators.http import condition @condition ( last_modified_func = latest_entry ) def front_page ( request , blog_id ): ... デコレータ ... 算するのが簡単な場合もあり、 Django は ETag だけ、あるいは last-modified だけを計算するデコレータを提供します。 django.views.decorators.http.etag と django.views.decorators.http.last_modified デコレータは condition デコレータと同じ型の関数を渡されます。これら ... 2026年10月08日