per page, with , order by , clip by
Results of 1 - 10 of about 60 for args (0.004 sec.)
ベース・ビュー 12273
ベース・ビュー 以下の3つのクラスは、Django のビューの作成に必要な多くの機能を提供します。これらは Django ビューの 親の ビューとみなすことができ、それ自体で使うことも継承して使うこともできます。プロジェクトに必要な全ての機能を提供するわけでは ... y : from django.http import HttpResponse from django.views import View class MyView ( View ): def get ( self , request , * args , ** kwargs ): return HttpResponse ( "Hello, World!" ) Example urls.py : from django.urls import path from myapp.views imp ... ト値: [ "get" , "post" , "put" , "patch" , "delete" , "head" , "options" , "trace" ] メソッド classmethod as_view ( ** initkwargs ) リクエストを受け取ってレスポンスを返す、呼び出し可能なビューを返します: response = MyView . as_view ()( request ) 返され ... たビューは、 view_class と view_initkwargs 属性を持っています。 リクエスト/レスポンスサイクル中にビューが呼び出されると、 setup() メソッドは HttpRequest をビューの r ...
https://man.mtool.work/django/6.1/ref/class-based-views/base.html
django.urls ユーティリティ関数 11808
django.urls ユーティリティ関数 reverse() reverse() 関数は指定したビューと任意のパラメータに対して、 url タグと同様に、絶対パス参照を返すために使用します。 reverse ( viewname , urlconf = None , args = None , kwargs = None , current_app = Non ... can't reverse namespaced views this way.) from news import views reverse ( views . archive ) URLが引数を受け入れる場合は、 args にそれらを渡すことができます。例えば: from django.urls import reverse def myview ( request ): return HttpResponseRedirect ... ( reverse ( "arch-summary" , args = [ 1945 ])) kwargs を args の代わりに渡すこともできます。例えば: >>> reverse ( "admin:app_list" , kwargs = { "app_label" ... : "auth" }) '/admin/auth/' args と kwargs を同時に reverse() に渡すことはできません。 一致するものが見つからない場合、 reverse() は NoReverseMatch 例外を発 ...
https://man.mtool.work/django/6.1/ref/urlresolvers.html
Django のショートカット関数 11342
Django のショートカット関数 django.shortcuts パッケージは、MVC の複数のレベルにまたがるヘルパー関数とクラスを集めたものです。言い換えれば、これらの関数やクラスは、便宜上、控えめな結合を取り入れます。 render() render ( request , template_nam ... } return HttpResponse ( t . render ( c , request ), content_type = "application/xhtml+xml" ) redirect() redirect ( to , * args , permanent = False , preserve_request = False , max_length = MAX_URL_REDIRECT_LENGTH , ** kwargs ) [ソース] 渡された引数に ... es the original request method. return redirect ( obj , preserve_request = True ) # ... resolve_url() resolve_url ( to , * args , ** kwargs ) [ソース] Returns a URL string by resolving and normalizing the given to argument into a concrete URL. The pa ... thod will be called and its result returned. A view name, view function, or view class, possibly with arguments passed as *args and **kwargs , in which case reverse() will be used to reverse-resolve the view. A URL string, which will be returned unch ...
https://man.mtool.work/django/6.1/topics/http/shortcuts.html
カスタムのモデルフィールドを作成する 10761
カスタムのモデルフィールドを作成する はじめに モデルリファレンス ドキュメントでは、Djangoの標準フィールドクラスである、 CharField や、 DateField などの使い方を説明しています。多くの場合、これらのクラスがあれば十分です。ただし、Djangoのバージ ... b import models class HandField ( models . Field ): description = "A hand of cards (bridge style)" def __init__ ( self , * args , ** kwargs ): kwargs [ "max_length" ] = 104 super () . __init__ ( * args , ** kwargs ) 私たちの HandField は、ほとんどの標 ... めにキーワード引数から削除できます: from django.db import models class HandField ( models . Field ): def __init__ ( self , * args , ** kwargs ): kwargs [ "max_length" ] = 104 super () . __init__ ( * args , ** kwargs ) def deconstruct ( self ): name , p ... ath , args , kwargs = super () . deconstruct () del kwargs [ "max_length" ] return name , path , args , kwargs 新しいキーワード引数を ...
https://man.mtool.work/django/6.1/howto/custom-model-fields.html
Tasks 9830
Tasks New in Django 6.0. The Task framework provides the contract and plumbing for background work, not the engine that runs it. The Tasks API defines how work is described, queued, and tracked, but leaves actual execution to external infra ... n 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_cl ... ask decorator: @task ( foo = 5 , bar = 600 ) def my_task (): pass Changed in Django 6.1: Support for passing arbitrary **kwargs to the @task decorator is added. If the defined Task is not valid according to the backend, InvalidTask is raised. See def ... ifying the following attributes: priority backend queue_name run_after See modifying Tasks for usage examples. enqueue ( * args , ** kwargs ) [ソース] Enqueues the Task to the Task backend for later execution. Arguments are passed to the Task 's func ...
https://man.mtool.work/django/6.1/ref/tasks.html
クラスベースのビューでミックスイン (mixin) を使用する 9365
クラスベースのビューでミックスイン (mixin) を使用する 注意 This is an advanced topic. A working knowledge of Django's class-based views is advised before exploring these techniques. Django のビルトインのクラスベースビューではたくさんの機能が ... ObjectMixin , View ): """Records the current user's interest in an author.""" model = Author def post ( self , request , * args , ** kwargs ): if not request . user . is_authenticated : return HttpResponseForbidden () # Look up the author we're inter ... self . get_object () # Actually record interest somehow here! return HttpResponseRedirect ( reverse ( "author-detail" , kwargs = { "pk" : self . object . pk }) ) 実際には、リレーショナルデータベースではなく、キーバリューストアに関心事を記録したいと思 ... SingleObjectMixin , ListView ): paginate_by = 2 template_name = "books/publisher_detail.html" def get ( self , request , * args , ** kwargs ): self . object = self . get_object ( queryset = Publisher . objects . all ()) return super () . get ( reques ...
https://man.mtool.work/django/6.1/topics/class-based-views/mixins.html
カスタム django-admin コマンドの作り方 9248
カスタム django-admin コマンドの作り方 manage.py を用いることで独自のアクションを登録する事ができます。例として、あなたが配布している Django アプリケーションに manage.py アクションを追加したくなったとします。このドキュメントでは、 このチュー ... : help = "Closes the specified poll for voting" def add_arguments ( self , parser ): parser . add_argument ( "poll_ids" , nargs = "+" , type = int ) def handle ( self , * args , ** options ): for poll_id in options [ "poll_ids" ]: try : poll = Poll . ... Command ( BaseCommand ): def add_arguments ( self , parser ): # Positional arguments parser . add_argument ( "poll_ids" , nargs = "+" , type = int ) # Named (optional) arguments parser . add_argument ( "--delete" , action = "store_true" , help = "Del ... ete poll instead of closing it" , ) def handle ( self , * args , ** options ): # ... if options [ "delete" ]: poll . delete () # ... The option ( delete in our example) is available in ...
https://man.mtool.work/django/6.1/howto/custom-management-commands.html
Django ユーティリティ (django.utils) 9016
Django ユーティリティ ( django.utils ) このドキュメントは、 django.utils のすべての安定したモジュールを対象としています。 django.utils 内のほとんどのモジュールは内部使用を目的としていることから、 内部リリース非推奨ポリシー に従い、以下に記載 ... ドルウェア は、 Accept-language ヘッダーによってキャッシュを区別するようにしています。 patch_cache_control ( response , ** kwargs ) [ソース] この関数は、キーワード引数を Cache-Control ヘッダーに追加することで、ヘッダーをパッチします。変換する内容は以下 ... ocess_request() , process_exception() , process_response() のようなメソッドを持っている)。 decorator_from_middleware_with_args ( middleware_class ) [ソース] decorator_from_middleware と似ていますが、 middleware_class に渡す引数を受け入れる関数を返し ... 。例えば、 cache_page() デコレータは CacheMiddleware からこのように作成されます: cache_page = decorator_from_middleware_with_args ( CacheMiddleware ) @cache_page ( 3600 ) def my_view ( request ): pass sync_only_middleware ( middleware ) [ソース] ミドル ...
https://man.mtool.work/django/6.1/ref/utils.html
ファイルのアップロード 8667
ファイルのアップロード Django がファイルアップロードを扱うとき、ファイルデータは request.FILES に格納されます ( request についての詳細は リクエスト/レスポンス オブジェクト を参照してください)。ここでは、ファイルがどのようにディスクとメモリに ... e import BaseCommand from django.core.files.base import ContentFile class MyCommand ( BaseCommand ): def handle ( self , * args , ** options ): content_file = ContentFile ( b "Hello world!" , name = "hello-world.txt" ) instance = ModelWithFileField ( ... learableFileInput ): allow_multiple_selected = True class MultipleFileField ( forms . FileField ): def __init__ ( self , * args , ** kwargs ): kwargs . setdefault ( "widget" , MultipleFileInput ()) super () . __init__ ( * args , ** kwargs ) def clean ... rotect @method_decorator ( csrf_exempt , name = "dispatch" ) class UploadFileView ( View ): def setup ( self , request , * args , ** kwargs ): request . upload_handlers . insert ( 0 , ProgressBarUploadHandler ( request )) super () . setup ( request , ...
https://man.mtool.work/django/6.1/topics/http/file-uploads.html
ミックスイン (mixin) を編集する 8434
ミックスイン (mixin) を編集する 以下のミックスイン (mixin) は、Djangoの編集ビューを構築するのに使用されます。 django.views.generic.edit.FormMixin django.views.generic.edit.ModelFormMixin django.views.generic.edit.ProcessFormView django.view ... ) インスタンス化するフォームクラスを取得します。デフォルトでは form_class です。 get_form ( form_class = None ) get_form_kwargs() を使用して form_class のインスタンスを生成します。 form_class が指定されていない場合は get_form_class() が使用されます。 ... get_form_kwargs () フォームのインスタンス化に必要なキーワード引数を構築します。 引数 initial には get_initial() を指定します。 リクエストが ... 。 form_invalid ( form ) 無効なフォームをコンテキストとして提供し、レスポンスをレンダリングします。 get_context_data ( ** kwargs ) get_form() を呼び出して、その結果を "form" という名前でコンテキストデータに追加します。 ModelFormMixin class django.view ...
https://man.mtool.work/django/6.1/ref/class-based-views/mixins-editing.html
PREV 1 2 3 4 5 6 NEXT