per page, with , order by , clip by
Results of 1 - 10 of about 15 for headline (0.008 sec.)
QuerySet API リファレンス 12156
QuerySet API リファレンス このドキュメントでは、 QuerySet API の詳細を説明しています。 モデル と データベースクエリ ガイドにある説明を前提としていますので、このドキュメントを読む前にこの 2 つを読んでおくことをおすすめします。 このリファレン ... et はイテラブルで、初めてイテレートした時にデータベースのクエリを実行します。たとえば、これはデータベースにある全エントリのheadline属性を出力するプログラムです: for e in Entry . objects . all (): print ( e . headline ) メモ: 1つ以上の結果が存在するかどうか ... も少なくとも1つ以上の結果が含まれれば True となり、そうでなければ False になります。例えば: if Entry . objects . filter ( headline = "Test" ): print ( "There is at least one Entry with the headline Test" ) 注意: もしクエリの結果が少なくとも1つ存在するか ... るSQLステートメントでは AND によって結合され、全体が NOT() によって囲まれます。 この例では pub_date が 2005-1-3より新しく、 headline が "Hello" であるようなエントリーを除外しています: Entry . objects . exclude ( pub_date__gt = datetime . date ( 2005 , 1 , ...
https://man.mtool.work/django/6.1/ref/models/querysets.html
多対一 (many-to-one) 関係 11703
多対一 (many-to-one) 関係 多対一のリレーションシップを定義するには ForeignKey を使います。 この例では、 Reporter は複数の Article オブジェクトと関連付けることができますが、 Article は一つの Reporter オブジェクトしか持つことができません: fro ... ilField () def __str__ ( self ): return f " { self . first_name } { self . last_name } " class Article ( models . Model ): headline = models . CharField ( max_length = 100 ) pub_date = models . DateField () reporter = models . ForeignKey ( Reporter , on_ ... delete = models . CASCADE ) def __str__ ( self ): return self . headline class Meta : ordering = [ "headline" ] 以下は、Python API の機能を使って実行できる操作の例です。 複数の Reporter を作成する ... il = "paul@example.com" ) >>> r2 . save () Article を作成する: >>> from datetime import date >>> a = Article ( id = None , headline = "This is a test" , pub_date = date ( 2005 , 7 , 27 ), reporter = r ) >>> a . save () >>> a . reporter . id 1 >>> a . rep ...
https://man.mtool.work/django/6.1/topics/db/examples/many_to_one.html
クエリを作成する 10536
クエリを作成する 一度 データモデル を作成すれば、Django はデータオブジェクトの作成、取得、更新および削除を行えるようにデータベースを抽象化した API を自動的に提供します。本ドキュメントではこの API をどのように用いるかを説明します。多様なモデ ... f ): return self . name class Entry ( models . Model ): blog = models . ForeignKey ( Blog , on_delete = models . CASCADE ) headline = models . CharField ( max_length = 255 ) body_text = models . TextField () pub_date = models . DateField () mod_date = mo ... = models . IntegerField ( default = 0 ) rating = models . IntegerField ( default = 5 ) def __str__ ( self ): return self . headline オブジェクトを作成する Djangoでは、データベースのテーブルデータをPythonオブジェクトで表現するために、直感的な仕組みを採用し ... 。そのため、複数のフィルタを連結することが可能です。たとえば、次のように書くことができます。 >>> Entry . objects . filter ( headline__startswith = "What" ) . exclude ( ... pub_date__gte = datetime . date . today () ... ) . filter ( pub_date__gte = datetim ...
https://man.mtool.work/django/6.1/topics/db/queries.html
多対多 (many-to-many) 関係 10240
多対多 (many-to-many) 関係 多対多の関係を定義するには、 ManyToManyField を使用します。 この例では、一つの Article は複数の Publication オブジェクトに掲載することができ、一つの Publication は複数の Article オブジェクトを持ちます: from django ... gth = 30 ) class Meta : ordering = [ "title" ] def __str__ ( self ): return self . title class Article ( models . Model ): headline = models . CharField ( max_length = 100 ) publications = models . ManyToManyField ( Publication ) class Meta : ordering = ... [ "headline" ] def __str__ ( self ): return self . headline 以下は、Python API の機能を使って実行できる操作の例です。 Publication イン ... p2 . save () >>> p3 = Publication ( title = "Science Weekly" ) >>> p3 . save () Article を一つ作ります: >>> a1 = Article ( headline = "Django lets you build web apps easily" ) 保存するまでは Publication と関連付けることはできません: >>> a1 . publications ...
https://man.mtool.work/django/6.1/topics/db/examples/many_to_many.html
データベースアクセスの最適化 10083
データベースアクセスの最適化 Djangoのデータベース層は、開発者がデータベースを最大限活用できるように、さまざまな方法を提供しています。このドキュメントでは、データベースアクセスを最適化する際にとるべき手順を、大まかにいくつかの見出しとしてまと ... モデル を使うと: >>> entry = Entry . objects . get ( id = 10 ) 上記は以下よりも高速です: >>> entry = Entry . objects . get ( headline = "News Item Title" ) これは、 id がデータベースによってインデックス化されていて、ユニークだと保証されているからです。 以下 ... のようにすると非常に遅くなる恐れがあります: >>> entry = Entry . objects . get ( headline__startswith = "News" ) まず第一に、 headline はインデックス化されておらず、データベースのデータ取り出しを遅くします。 Seco ... , use the bulk_create() method to reduce the number of SQL queries. For example: Entry . objects . bulk_create ( [ Entry ( headline = "This is a test" ), Entry ( headline = "This is only a test" ), ] ) ...これは下記よりも適切です: Entry . objects . creat ...
https://man.mtool.work/django/6.1/topics/db/optimization.html
モデルからフォームを作成する 8708
モデルからフォームを作成する ModelForm class ModelForm [ソース] データベース中心のアプリケーションを作成している場合、Django モデルに密接にマップするフォームを使うことになるでしょう。例えば、 BlogComment モデルを持っていて、閲覧者がコメント ... ate the form class. >>> class ArticleForm ( ModelForm ): ... class Meta : ... model = Article ... fields = [ "pub_date" , "headline" , "content" , "reporter" ] ... # Creating a form to add an article. >>> form = ArticleForm () # Creating a form to change ... rm from myapp.models import Article class ArticleForm ( ModelForm ): class Meta : model = Article fields = [ "pub_date" , "headline" , "content" , "reporter" , "slug" ] field_classes = { "slug" : MySlugFormField , } もしくは: from django.forms import Mod ... db_field . formfield ( ** kwargs ) class ArticleForm ( ModelForm ): class Meta : model = Article fields = [ "pub_date" , "headline" , "content" , "reporter" , "slug" ] formfield_callback = formfield_for_dbfield 最後に、フィールドを完全に -- タイプ、バリ ...
https://man.mtool.work/django/6.1/topics/forms/modelforms.html
Django の概要 8464
Django の概要 Django は変転の激しいニュースルーム環境で開発された経緯から、よくある Web 開発タスクを迅速かつ簡単化するように設計されています。ここでは Django による データベースを使った Web アプリケーション開発をざっと見てみましょう。 このド ... th = 70 ) def __str__ ( self ): return self . full_name class Article ( models . Model ): pub_date = models . DateField () headline = models . CharField ( max_length = 200 ) content = models . TextField () reporter = models . ForeignKey ( Reporter , on_d ... elete = models . CASCADE ) def __str__ ( self ): return self . headline モデルのインストール 次に、データベーステーブルを自動で作成する Django のコマンドラインユーティリティを実行します。 /  ... query does not exist. # Create an article. >>> from datetime import date >>> a = Article ( ... pub_date = date . today (), headline = "Django is cool" , content = "Yeah." , reporter = r ... ) >>> a . save () # Now the article is in the database. >>> Arti ...
https://man.mtool.work/django/6.1/intro/overview.html
モデル index リファレンス 7924
モデル index リファレンス Index クラスを利用すると、データベースのインデックスの作成が簡単になります。インデックスは、 Meta.indexes オプションを使用して追加できます。このドキュメントでは、 index options を含む Index の API リファレンスを説明 ... されます。カラムに対して降順のインデックスを定義するには、フィールド名の前にハイフンを追加します。 たとえば、 Index(fields=['headline', '-pub_date']) は (headline, pub_date DESC) を持つ SQL を作成します。 name Index. name インデックスの名前。 name が与えら ... するクエリに対して、インデックスのみのスキャンが利用できるようになります。 例: Index ( name = "covering_index" , fields = [ "headline" ], include = [ "pub_date" ]) この例は、データをインデックスからのみ取得しながら、 headline のフィルタリングと、 pub_date ...
https://man.mtool.work/django/6.1/ref/models/indexes.html
PostgreSQL 固有の集計関数 7854
PostgreSQL 固有の集計関数 これらの機能は、 django.contrib.postgres.aggregates モジュールから利用可能です。これらについての詳細は、 PostgreSQLドキュメント に記載されています。 注釈 すべての関数はデフォルトのエイリアスを持たないので、明示的に ... 用例: class Publication ( models . Model ): title = models . CharField ( max_length = 30 ) class Article ( models . Model ): headline = models . CharField ( max_length = 100 ) publications = models . ManyToManyField ( Publication ) >>> article = Article . ... objects . create ( headline = "NASA uses Python" ) >>> article . publications . create ( title = "The Python Journal" ) <Publication: Publication obje ... ingAgg ( ... "publications__title" , ... delimiter = ", " , ... order_by = "publications__title" , ... ) ... ) . values ( "headline" , "publication_names" ) <QuerySet [{ 'headline': 'NASA uses Python', 'publication_names': 'Science News, The Python Journ ...
https://man.mtool.work/django/6.1/ref/contrib/postgres/aggregates.html
全文検索 7784
全文検索 django.contrib.postgres.search モジュールのデータベース関数は PostgreSQL の 全文検索エンジン を利用しやすくしています。 このドキュメントの例では、 クエリを作成する で定義されたモデルを使用します。 参考 検索の概要については、 トピッ ... lue ( 4 )), ... ) ... ) PostgreSQLのドキュメントに、 different rank normalization options についての詳細があります。 SearchHeadline class SearchHeadline ( expression , query , config = None , start_sel = None , stop_sel = None , max_words = None , min_wo ... highlighting search results に関する詳細が記載されています。 使用例: >>> from django.contrib.postgres.search import SearchHeadline , SearchQuery >>> query = SearchQuery ( "red tomato" ) >>> entry = Entry . objects . annotate ( ... headline = SearchHeadl ... "body_text" , ... query , ... start_sel = "<span>" , ... stop_sel = "</span>" , ... ), ... ) . get () >>> print ( entry . headline ) Sandwich with <span>tomato</span> and <span>red</span> cheese. config パラメータの説明については、 検索設定を変更する を ...
https://man.mtool.work/django/6.1/ref/contrib/postgres/search.html
PREV 1 2 NEXT