per page, with , order by , clip by
Results of 1 - 10 of about 71 for init (0.005 sec.)
シグナル 12875
シグナル Djangoが送信する全てのシグナルのリストです。全ての組み込みシグナルは send() メソッドを使用して送信されます。 参考 シグナルの登録方法と受信方法に関する情報については、 シグナルディスパッチャ のドキュメントを参照してください。 認証フ ... モデルのシグナルを使用する前に モデルメソッドをオーバーライド することを検討してください。 警告 これらのシグナルの多くは、 __init__() や save() のような、自分のコードでオーバーライドできる様々なモデルメソッドによって送信されます。 これらのメソッドをモデ ... lls.Question' として参照できます。この種の参照は、循環インポートの依存関係や交換可能なモデルを扱う際に非常に便利です。 pre_init django.db.models.signals. pre_init Django モデルをインスタンス化するたびに、このシグナルはモデルの __init__() メソッドの開 ... されます。 このシグナルとともに送信される引数は以下の通りです: sender たった今インスタンスが作成されたモデルクラス。 args __init__() に渡される位置引数のリストです。 kwargs __init__() に渡されるキーワード引数の辞書。 例えば、 チュートリアル にはこのよ ...
https://man.mtool.work/django/6.1/ref/signals.html
カスタムのモデルフィールドを作成する 12720
カスタムのモデルフィールドを作成する はじめに モデルリファレンス ドキュメントでは、Djangoの標準フィールドクラスである、 CharField や、 DateField などの使い方を説明しています。多くの場合、これらのクラスがあれば十分です。ただし、Djangoのバージ ... rth , east , south and west . Our class looks something like this: class Hand : """A hand of cards (bridge style)""" def __init__ ( self , north , east , south , west ): # Input parameters are lists of cards ('Ah', '9s', etc.) self . north = north se ... eld クラスをサブクラス化すべきです。 新しいフィールドの初期化は、ケース固有の引数を共通の引数から分離し、後者を Field の __init__() メソッドに渡すことです。 (または親クラスに対して)。 この例では、フィールドを HandField と呼ぶことにします。( Field ... ます。 from django.db 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 ) 私たちの HandFie ...
https://man.mtool.work/django/6.1/howto/custom-model-fields.html
Migrating email to mailers 9572
Migrating email to mailers Django 6.1 introduced the MAILERS setting, replacing EMAIL_BACKEND and several other EMAIL_* settings. It also introduced mail.mailers for obtaining configured email backend instances, replacing mail.get_connectio ... ail backends Custom EmailBackend implementations may need to be updated for compatibility with mailers. In the backend's __init__() method, accept explicit keyword arguments for all configuration options that can come from "OPTIONS" . Backends that u ... choose), but keyword arguments should take precedence over settings. Accept variable **kwargs and pass them to superclass init. (This will include a new alias argument which must be passed to the superclass.) Ensure that any **kwargs used by the bac ... kend are not passed to superclass init, as that would generate an InvalidMailer error for unknown OPTIONS. Backends must now handle fail_silently themselves, if ...
https://man.mtool.work/django/6.1/howto/mailers-migration.html
クエリ式 (Query Expression) 9572
クエリ式 (Query Expression) クエリ式 (query expression) は、update、create、filter、order by、annotation、またはaggregateの一部として使用できる値または計算を記述します。式が真偽値を出力する場合、フィルタで直接使用できます。クエリの記述に使用 ... eld). function = "SUM" template = " %(function)s ( %(all_values)s%(expressions)s )" allow_distinct = False arity = 1 def __init__ ( self , expression , all_values = False , ** extra ): super () . __init__ ( expression , all_values = "ALL " if all_val ... す。この関数は NULL でない最初のカラムまたは値を返します。 まずはSQL生成に使用するテンプレートと、いくつかの属性を設定する __init__() メソッドを定義します: from django.db.models import Expression class Coalesce ( Expression ): template = "COALESCE( %(e ... xpressions)s )" def __init__ ( self , expressions , output_field ): super () . __init__ ( output_field = output_field ) if len ( expressions ) < 2 : ...
https://man.mtool.work/django/6.1/ref/models/expressions.html
カスタム django-admin コマンドの作り方 9417
カスタム django-admin コマンドの作り方 manage.py を用いることで独自のアクションを登録する事ができます。例として、あなたが配布している Django アプリケーションに manage.py アクションを追加したくなったとします。このドキュメントでは、 このチュー ... oは、そのディレクトリ内のアンダーバーで始まらないPythonモジュールすべてを manage.py コマンドに登録します。例えば: polls/ __init__.py models.py management/ __init__.py commands/ __init__.py _private.py closepoll.py tests.py views.py この例では、 close ... dle() メソッドだけは、実装する必要があります。 サブクラス内でのコンストラクタの実装 BaseCommand を継承したサブクラス内で __init__ を実装する場合、 BaseCommand の __init__ を呼び出す必要があります: class Command ( BaseCommand ): def __init__ ( self , ... * args , ** kwargs ): super () . __init__ ( * args , ** kwargs ) # ... BaseCommand. create_parser ( prog_name , subcommand , ** kwargs ) [ソース] CommandParser イ ...
https://man.mtool.work/django/6.1/howto/custom-management-commands.html
独自のテンプレートタグとフィルタを作る 9417
独自のテンプレートタグとフィルタを作る Django のテンプレート言語は、アプリケーションのプレゼンテーションロジックのニーズに対応するように設計された、多種多様な 埋め込みタグやフィルタ を搭載しています。それでもなお、テンプレート構成要素のコア ... gs" ディレクトリを含むべきです。まだ存在していない場合は、ディレクトリが Python パッケージとして扱われるようにするため、"__init__.py" を忘れないでください。 開発用サーバが自動的にリスタートしない場合 templatetags モジュールを追加した後、テンプレートで ... 例えば、カスタムタグ/フィルタが poll_extras.py というファイルにある場合、アプリのレイアウトは次のようになります: polls/ __init__.py models.py templatetags/ __init__.py poll_extras.py views.py そして、テンプレートでは次のように使います: {% load poll_ ... ango.utils.safestring import mark_safe register = template . Library () @register . filter ( needs_autoescape = True ) def initial_letter_filter ( text , autoescape = True ): first , other = text [ 0 ], text [ 1 :] if autoescape : esc = conditional_e ...
https://man.mtool.work/django/6.1/howto/custom-template-tags.html
はじめての Django アプリ作成、その 1 9248
はじめての Django アプリ作成、その 1 さあ、例を交えながら学んでゆきましょう。 このチュートリアルでは、簡単な投票 (poll) アプリケーションの作成に取り組ん でもらいます。 Poll アプリケーションは 2 つの部分からなります: ユーザが投票したり結果を ... 衝突します) を使わないようにしましょう。 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 の初心者は、 Pytho ... \> py manage.py startapp polls このコマンドは polls というディレクトリを作成します。中身はこのようになっています: polls/ __init__.py admin.py apps.py migrations/ __init__.py models.py tests.py views.py このディレクトリ構造が、 poll アプリケーションの ...
https://man.mtool.work/django/6.1/intro/tutorial01.html
ミドルウェア (Middleware) 8785
ミドルウェア (Middleware) ミドルウェアは、Django のリクエスト/レスポンス処理にフックを加えるためのフレームワークです。これは、Django の入力あるいは出力をグローバルに置き換えるための、軽量で低レベルの「プラグイン」システムです。 各ミドルウェ ... ドルウェアは、以下のように関数として書くことができます: def simple_middleware ( get_response ): # One-time configuration and initialization. def middleware ( request ): # Code to be executed for each request before # the view (and later middleware) are ... nse return middleware もしくは、インスタンスを呼び出し可能なクラスとして書くこともできます: class SimpleMiddleware : def __init__ ( self , get_response ): self . get_response = get_response # One-time configuration and initialization. def __call__ ( ... かについての詳細は 非同期サポート を参照してください。 ミドルウェアは、あなたの Ptyhon パスのどこでも使うことができます。 __init__(get_response) ミドルウェアファクトリは get_response 引数を受け取る必要があります。ミドルウェアに対してグローバルな宣言を ...
https://man.mtool.work/django/6.1/topics/http/middleware.html
フォーム フィールド 8461
フォーム フィールド class Field [ソース] Form クラスを作成時の一番重要な部分は、form のフィールド (field) の定義です。各フィールドにはカスタムの検証ロジックがあり、他にいくつかのフックもあります。 Field. clean ( value ) [ソース] Field クラス ... l for="id_captcha_answer">2 + 2 =</label><input type="number" name="captcha_answer" required id="id_captcha_answer"></div> initial Field. initial initial 属性は、 Field が結びつけられていない Form で表示されるときに使われる初期値を指定します。 動的に ... 初期値を指定する方法は、 Form.initial パラメータを参照してください。 これの使用例は、あるフィールドが特定の値で初期化された「空」のフォームを表示したい場合で ... す。例えば: >>> from django import forms >>> class CommentForm ( forms . Form ): ... name = forms . CharField ( initial = "Your name" ) ... url = forms . URLField ( initial = "https://" ) ... comment = forms . CharField () ... >>> f = Comm ...
https://man.mtool.work/django/6.1/ref/forms/fields.html
テンプレートのバックエンドをカスタマイズする 8307
テンプレートのバックエンドをカスタマイズする カスタムのバックエンド ここでは、他のテンプレートシステムを使用するために、カスタムテンプレートバックエンドを実装する方法を説明します。テンプレートバックエンドは django.template.backends.base.Bas ... the subdirectory containing the templates for this engine # inside an installed application. app_dirname = "foobar" def __init__ ( self , params ): params = params . copy () options = params . pop ( "OPTIONS" ) . copy () super () . __init__ ( params ... self ) except foobar . TemplateCompilationFailed as exc : raise TemplateSyntaxError ( exc . args ) class Template : def __init__ ( self , template ): self . template = template def render ( self , context = None , request = None ): if context is Non ...
https://man.mtool.work/django/6.1/howto/custom-template-backend.html
PREV 1 2 3 4 5 6 7 8 NEXT