per page, with , order by , clip by
Results of 1 - 10 of about 310 for return (0.005 sec.)
独自のテンプレートタグとフィルタを作る — Django 6.1 ドキュメント 8658
Django 6.1 ドキュメント Home | Table of contents | Index | Modules « previous | up | next » 独自のテンプレートタグとフィルタを作る ¶ Django のテンプレート言語は、アプリケーションのプレゼンテーションロジックのニーズに対応するように設計された ... も適切でしょう。 以下はフィルタ定義の例です: def cut ( value , arg ): """Removes all values of arg from the given string""" return value . replace ( arg , "" ) そして、以下はフィルタがどのように使われるかの例です: {{ somevariable | cut :"0" }} ほとんどの ... ように関数の第2引数を省略してください: def lower ( value ): # Only one argument. """Converts a string into all lowercase""" return value . lower () 独自のフィルタを登録する ¶ django.template.Library. filter () ¶ フィルタ定義を書き終わったら、Django のテ ... 。 代わりに register.filter() をデコレータとして使用できます。 @register . filter ( name = "cut" ) def cut ( value , arg ): return value . replace ( arg , "" ) @register . filter def lower ( value ): return value . lower () name 引数を省略した場合、上記 ...
https://man.mtool.work/django/6.1/howto/custom-template-tags.html
独自のテンプレートタグとフィルタを作る — Django 6.1 ドキュメント 8658
Django 6.1 ドキュメント Home | Table of contents | Index | Modules « previous | up | next » 独自のテンプレートタグとフィルタを作る ¶ Django のテンプレート言語は、アプリケーションのプレゼンテーションロジックのニーズに対応するように設計された ... も適切でしょう。 以下はフィルタ定義の例です: def cut ( value , arg ): """Removes all values of arg from the given string""" return value . replace ( arg , "" ) そして、以下はフィルタがどのように使われるかの例です: {{ somevariable | cut :"0" }} ほとんどの ... ように関数の第2引数を省略してください: def lower ( value ): # Only one argument. """Converts a string into all lowercase""" return value . lower () 独自のフィルタを登録する ¶ django.template.Library. filter () ¶ フィルタ定義を書き終わったら、Django のテ ... 。 代わりに register.filter() をデコレータとして使用できます。 @register . filter ( name = "cut" ) def cut ( value , arg ): return value . replace ( arg , "" ) @register . filter def lower ( value ): return value . lower () name 引数を省略した場合、上記 ...
https://man.mtool.work/django/6.1/howto/custom-template-tags.html
クラスベースのビューでフォームを扱う — Django 6.1 ドキュメント 8210
Django 6.1 ドキュメント Home | Table of contents | Index | Modules « previous | up | next » クラスベースのビューでフォームを扱う ¶ フォームの処理には、一般に3つの場合分けが存在します。 最初の GET リクエスト (空白またはデフォルト値が埋め込ま ... url = "/thanks/" def form_valid ( self , form ): # This method is called when valid form data has been POSTed. # It should return an HttpResponse. form . send_email () return super () . form_valid ( form ) メモ: FormView は TemplateResponseMixin を継承 ... ey can work out which model class to use: model 属性が与えられた場合には、そのモデルクラスが使用されます。 If get_object() returns an object, the class of that object will be used. queryset が与えられた場合には、そのクエリセットに対するモデルが使用され ... ort reverse class Author ( models . Model ): name = models . CharField ( max_length = 200 ) def get_absolute_url ( self ): return reverse ( "author-detail" , kwargs = { "pk" : self . pk }) そうしたら、 CreateView およびその仲間たちを使って実際に動作させ ...
https://man.mtool.work/django/6.1/topics/class-based-views/generic-editing.html
クラスベースのビューでフォームを扱う — Django 6.1 ドキュメント 8144
Django 6.1 ドキュメント Home | Table of contents | Index | Modules « previous | up | next » クラスベースのビューでフォームを扱う ¶ フォームの処理には、一般に3つの場合分けが存在します。 最初の GET リクエスト (空白またはデフォルト値が埋め込ま ... url = "/thanks/" def form_valid ( self , form ): # This method is called when valid form data has been POSTed. # It should return an HttpResponse. form . send_email () return super () . form_valid ( form ) メモ: FormView は TemplateResponseMixin を継承 ... ey can work out which model class to use: model 属性が与えられた場合には、そのモデルクラスが使用されます。 If get_object() returns an object, the class of that object will be used. queryset が与えられた場合には、そのクエリセットに対するモデルが使用され ... ort reverse class Author ( models . Model ): name = models . CharField ( max_length = 200 ) def get_absolute_url ( self ): return reverse ( "author-detail" , kwargs = { "pk" : self . pk }) そうしたら、 CreateView およびその仲間たちを使って実際に動作させ ...
https://man.mtool.work/django/6.1/topics/class-based-views/generic-editing.html
クラスベースのビューでミックスイン (mixin) を使用する — Django 6.1 ドキュメント 8144
Django 6.1 ドキュメント Home | Table of contents | Index | Modules « previous | up | next » クラスベースのビューでミックスイン (mixin) を使用する ¶ 注意 This is an advanced topic. A working knowledge of Django's class-based views is advised ... ュー内のテンプレートを扱うインターフェースに一貫性を保ちやすくなっています。 TemplateResponseMixin Every built in view which returns a TemplateResponse will call the render_to_response() method that TemplateResponseMixin provides. Most of the time this w ... lateView and DetailView ); similarly, it's unlikely that you'll need to override it, although if you want your response to return something not rendered via a Django template then you'll want to do it. For an example of this, see the JSONResponseMixin ... , should call get_context_data() passing any data they want to ensure is in there as keyword arguments. get_context_data() returns a dictionary; in ContextMixin it returns its keyword arguments, but it is common to override this to add more members to ...
https://man.mtool.work/django/6.1/topics/class-based-views/mixins.html
クラスベースのビューでミックスイン (mixin) を使用する — Django 6.1 ドキュメント 8079
Django 6.1 ドキュメント Home | Table of contents | Index | Modules « previous | up | next » クラスベースのビューでミックスイン (mixin) を使用する ¶ 注意 This is an advanced topic. A working knowledge of Django's class-based views is advised ... ュー内のテンプレートを扱うインターフェースに一貫性を保ちやすくなっています。 TemplateResponseMixin Every built in view which returns a TemplateResponse will call the render_to_response() method that TemplateResponseMixin provides. Most of the time this w ... lateView and DetailView ); similarly, it's unlikely that you'll need to override it, although if you want your response to return something not rendered via a Django template then you'll want to do it. For an example of this, see the JSONResponseMixin ... , should call get_context_data() passing any data they want to ensure is in there as keyword arguments. get_context_data() returns a dictionary; in ContextMixin it returns its keyword arguments, but it is common to override this to add more members to ...
https://man.mtool.work/django/6.1/topics/class-based-views/mixins.html
Django のショートカット関数 — Django 6.1 ドキュメント 7433
Django 6.1 ドキュメント Home | Table of contents | Index | Modules « previous | up | next » Django のショートカット関数 ¶ django.shortcuts パッケージは、MVC の複数のレベルにまたがるヘルパー関数とクラスを集めたものです。言い換えれば、これらの ... てレンダリングされたテキストを持つ、 HttpResponse オブジェクトを返します。 Django does not provide a shortcut function which returns a TemplateResponse because the constructor of TemplateResponse offers the same level of convenience as render() . 必須の引 ... tion/xhtml+xml でレンダリングしてみます。 from django.shortcuts import render def my_view ( request ): # View code here... return render ( request , "myapp/index.html" , { "foo" : "bar" , }, content_type = "application/xhtml+xml" , ) この例は次のコード ... loader def my_view ( request ): # View code here... t = loader . get_template ( "myapp/index.html" ) c = { "foo" : "bar" } return HttpResponse ( t . render ( c , request ), content_type = "application/xhtml+xml" ) redirect() ¶ redirect ( to , * args , ...
https://man.mtool.work/django/6.1/topics/http/shortcuts.html
Django のショートカット関数 — Django 6.1 ドキュメント 7368
Django 6.1 ドキュメント Home | Table of contents | Index | Modules « previous | up | next » Django のショートカット関数 ¶ django.shortcuts パッケージは、MVC の複数のレベルにまたがるヘルパー関数とクラスを集めたものです。言い換えれば、これらの ... てレンダリングされたテキストを持つ、 HttpResponse オブジェクトを返します。 Django does not provide a shortcut function which returns a TemplateResponse because the constructor of TemplateResponse offers the same level of convenience as render() . 必須の引 ... tion/xhtml+xml でレンダリングしてみます。 from django.shortcuts import render def my_view ( request ): # View code here... return render ( request , "myapp/index.html" , { "foo" : "bar" , }, content_type = "application/xhtml+xml" , ) この例は次のコード ... loader def my_view ( request ): # View code here... t = loader . get_template ( "myapp/index.html" ) c = { "foo" : "bar" } return HttpResponse ( t . render ( c , request ), content_type = "application/xhtml+xml" ) redirect() ¶ redirect ( to , * args , ...
https://man.mtool.work/django/6.1/topics/http/shortcuts.html
Django's Tasks framework — Django 6.1 ドキュメント 7368
Django 6.1 ドキュメント Home | Table of contents | Index | Modules « previous | up | next » Django's Tasks framework ¶ New in Django 6.0: For older Django versions, the django-tasks backport is available. For a web application, there's ofte ... from django.core.mail import send_mail from django.tasks import task @task def email_users ( emails , subject , message ): return send_mail ( subject = subject , message = message , from_email = None , recipient_list = emails ) The return value of the ... om django.tasks import task @task ( priority = 2 , queue_name = "emails" ) def email_users ( emails , subject , message ): return send_mail ( subject = subject , message = message , from_email = None , recipient_list = emails ) By convention, Tasks are ... logger . debug ( f "Attempt { context . attempt } to send user email. Task result id: { context . task_result . id } ." ) return send_mail ( subject = subject , message = message , from_email = None , recipient_list = emails ) Modifying Tasks ¶ Before ...
https://man.mtool.work/django/6.1/topics/tasks.html
カスタムのモデルフィールドを作成する — Django 6.1 ドキュメント 7237
Django 6.1 ドキュメント Home | Table of contents | Index | Modules « previous | up | next » カスタムのモデルフィールドを作成する ¶ はじめに ¶ モデルリファレンス ドキュメントでは、Djangoの標準フィールドクラスである、 CharField や、 DateField ... ** kwargs ) def deconstruct ( self ): name , path , args , kwargs = super () . deconstruct () del kwargs [ "max_length" ] return name , path , args , kwargs 新しいキーワード引数を追加する場合、自分で kwargs に値を設定する deconstruct() でコードを記述す ... uct () # Only include kwarg if it's not the default if self . separator != "," : kwargs [ "separator" ] = self . separator return name , path , args , kwargs より複雑な例はこのドキュメントの範囲外ですが、これだけは覚えておいてください - deconstruct() は ... no-opの AlterField 操作を検出します。 例えば: class CommaSepField ( models . Field ): @property def non_db_attrs ( self ): return super () . non_db_attrs + ( "separator" ,) カスタムフィールドのベースクラスを変更する ¶ カスタムフィールドの基底クラスを変 ...
https://man.mtool.work/django/6.1/howto/custom-model-fields.html
PREV 1 2 3 4 5 6 7 8 9 10 NEXT