... structure. Task definition The task decorator task ( * , priority = 0 , queue_name = 'default' , backend = 'default' , takes_context = False , ** kwargs ) [ソース] The ... @task decorator defines a Task instance. All keyword arguments are passed directly to the backend's task_class (which defaults to Task ). ... stom Task backends may define a custom task_class that accepts additional arguments. These can be passed through the @task decorator: @task ( foo = 5 , bar = 600 ) def my_task (): pass Changed in Django 6.1: Support for passing arbitrary **kwargs to the @ ... ... ッドの結果をデコレートします。これが最も簡単にできる場所は、ビューをデプロイする URLconf の中です。 from django.contrib.auth.decorators import login_required , permission_required from django.views.generic import TemplateView from .views import VoteView url ... 数デコレータを単純にそのままメソッドに適用することはできません。適用前にメソッドデコレータに変換する必要があります。 method_decorator デコレータを使えば、関数デコレータをメソッドデコレータに変換し、インスタンスのメソッドのデコレーションに使えるようにできま ... す。たとえば、次のように使用します。 from django.contrib.auth.decorators import login_required from django.utils.decorators import method_decorator from django.views.generic import TemplateView ... ... coration of the add_view and user_change_password user admin views with sensitive_post_parameters() did not include method_decorator() (required since the views are methods) resulting in the decorator not being properly applied. This usage has been fixed ... ... coration of the add_view and user_change_password user admin views with sensitive_post_parameters() did not include method_decorator() (required since the views are methods) resulting in the decorator not being properly applied. This usage has been fixed ... ... 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 be ... mpletely in Django 1.4, in favor of a template tag that should be inserted into forms. All contrib apps use a csrf_protect decorator to protect the view. This requires the use of the csrf_token template tag in the template. If you have used custom templat ... 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 the ... ... ses marked with private Cache-Control directives when using mixed or uppercase values (e.g. Private ). The cache_control() decorator and patch_cache_control() function were not affected, since they normalize directives to lowercase. This issue only affect ... CVE-2026-35193: Potential exposure of private data via missing Vary: Authorization UpdateCacheMiddleware and cache_page() decorator allowed responses to requests bearing an Authorization header (and without Cache-Control: public ) to be cached. To confor ... ... ses marked with private Cache-Control directives when using mixed or uppercase values (e.g. Private ). The cache_control() decorator and patch_cache_control() function were not affected, since they normalize directives to lowercase. This issue only affect ... CVE-2026-35193: Potential exposure of private data via missing Vary: Authorization UpdateCacheMiddleware and cache_page() decorator allowed responses to requests bearing an Authorization header (and without Cache-Control: public ) to be cached. To confor ... ... ot be represented by timedelta . Changed in Django 6.1: ISO 8601 duration parsing now supports weeks ( PnW ). django.utils.decorators method_decorator ( decorator , name = '' ) [ソース] 関数デコレータをメソッドデコレータに変換します。これは、メソッドまたは ... クラスをデコレートするのに使用できます。後者の場合、 name はデコレートされるメソッドの名前であり、必須です。 decorator は関数のリストまたはタプルでも構いません。それらは逆順でラップされるため、呼び出しの順序は関数がリスト/タプル内に登場する順 ... 序となります。 使用方法の例については、 クラスベースビューのデコレート を参照してください。 decorator_from_middleware ( middleware_class ) [ソース] ミドルウェアクラスが与えられた場合、ビューデコレータを返します。これにより、 ... ... なります。 pymemcache 3.4.0 以降が必要です。詳細は Django におけるキャッシュについてのドキュメント を参照してください。 New decorators for the admin site The new display() decorator allows for easily adding options to custom display functions that can be u ... sed with list_display or readonly_fields . Likewise, the new action() decorator allows for easily adding options to action functions that can be used with actions . Using the @display decorator has the ... advantage that it is now possible to use the @property decorator when needing to specify attributes on the custom method. Prior to this it was necessary to use the property() function ins ... ... ask_backend : from django.tasks import default_task_backend Defining Tasks Tasks are defined using the django.tasks.task() decorator on a module-level function: from django.core.mail import send_mail from django.tasks import task @task def email_users ( e ... send_mail ( subject = subject , message = message , from_email = None , recipient_list = emails ) The return value of the decorator is a Task instance. Task attributes can be customized via the @task decorator arguments: from django.core.mail import send ... 2026年10月08日