... ) で利用できます。 Django がビューから送り返す各ページ (レスポンス) に対して、Django は2種類の HTTP ヘッダ、 ETag ヘッダと Last-Modified ヘッダを提供できます。これらのヘッダは HTTP レスポンス上ではオプションです。ヘッダはビュー関数で設定することも、 ... esource, it might send along a header such as either If-Modified-Since or If-Unmodified-Since , containing the date of the last modification time it was sent, or either If-Match or If-None-Match , containing the last ETag it was sent. If the current ... を計算して通常のビューを呼び出します。 condition デコレータのシグネチャは次のようになります。 condition ( etag_func = None , last_modified_func = None ) ETag と最終更新時間を計算するための2つの関数は、受信した request オブジェクトと、それらがサポートす ... ... ) で利用できます。 Django がビューから送り返す各ページ (レスポンス) に対して、Django は2種類の HTTP ヘッダ、 ETag ヘッダと Last-Modified ヘッダを提供できます。これらのヘッダは HTTP レスポンス上ではオプションです。ヘッダはビュー関数で設定することも、 ... esource, it might send along a header such as either If-Modified-Since or If-Unmodified-Since , containing the date of the last modification time it was sent, or either If-Match or If-None-Match , containing the last ETag it was sent. If the current ... を計算して通常のビューを呼び出します。 condition デコレータのシグネチャは次のようになります。 condition ( etag_func = None , last_modified_func = None ) ETag と最終更新時間を計算するための2つの関数は、受信した request オブジェクトと、それらがサポートす ... ... ません: from django.db import models class Reporter ( models . Model ): first_name = models . CharField ( max_length = 30 ) last_name = models . CharField ( max_length = 30 ) email = models . EmailField () def __str__ ( self ): return f " { self . fir ... st_name } { self . last_name } " class Article ( models . Model ): headline = models . CharField ( max_length = 100 ) pub_date = models . DateFiel ... 下は、Python API の機能を使って実行できる操作の例です。 複数の Reporter を作成する: >>> r = Reporter ( first_name = "John" , last_name = "Smith" , email = "john@example.com" ) >>> r . save () >>> r2 = Reporter ( first_name = "Paul" , last_name = "Jones ... ... ださい。 from django.db import models class Person ( models . Model ): first_name = models . CharField ( max_length = 100 ) last_name = models . CharField ( max_length = 100 ) birthdate = models . DateField () class Meta : constraints = [ models . Uni ... queConstraint ( fields = [ "first_name" , "last_name" ], name = "unique_first_last_name" , ), ] class Book ( models . Model ): name = models . CharField ( max_length = 10 ... on のデフォルトの Manager を get_by_natural_key() を使用して定義します。Person の場合、よいナチュラルキーは、first name と last name のペアになるでしょう。 from django.db import models class PersonManager ( models . Manager ): def get_by_natural_key ... ... ださい。 from django.db import models class Person ( models . Model ): first_name = models . CharField ( max_length = 100 ) last_name = models . CharField ( max_length = 100 ) birthdate = models . DateField () class Meta : constraints = [ models . Uni ... queConstraint ( fields = [ "first_name" , "last_name" ], name = "unique_first_last_name" , ), ] class Book ( models . Model ): name = models . CharField ( max_length = 10 ... on のデフォルトの Manager を get_by_natural_key() を使用して定義します。Person の場合、よいナチュラルキーは、first name と last name のペアになるでしょう。 from django.db import models class PersonManager ( models . Manager ): def get_by_natural_key ... ... ません: from django.db import models class Reporter ( models . Model ): first_name = models . CharField ( max_length = 30 ) last_name = models . CharField ( max_length = 30 ) email = models . EmailField () def __str__ ( self ): return f " { self . fir ... st_name } { self . last_name } " class Article ( models . Model ): headline = models . CharField ( max_length = 100 ) pub_date = models . DateFiel ... 下は、Python API の機能を使って実行できる操作の例です。 複数の Reporter を作成する: >>> r = Reporter ( first_name = "John" , last_name = "Smith" , email = "john@example.com" ) >>> r . save () >>> r2 = Reporter ( first_name = "Paul" , last_name = "Jones ... ... かりやすいでしょう。次のようなモデルがあるとします: class Person ( models . Model ): first_name = models . CharField ( ... ) last_name = models . CharField ( ... ) birth_date = models . DateField ( ... ) このとき、以下のように独自の SQL を実行できます: ... 重要ではありません。つまり、以下のクエリはどちらも同じように動作します: >>> Person . objects . raw ( "SELECT id, first_name, last_name, birth_date FROM myapp_person" ) >>> Person . objects . raw ( "SELECT last_name, birth_date, first_name, id FROM myap ... れば、簡単に Person のインスタンスにマッピングできます: >>> Person . objects . raw ( """ ... SELECT first AS first_name, ... last AS last_name, ... bd AS birth_date, ... pk AS id, ... FROM some_other_table ... """ ) ... 名称が一致している限り、そのモデ ... ... かりやすいでしょう。次のようなモデルがあるとします: class Person ( models . Model ): first_name = models . CharField ( ... ) last_name = models . CharField ( ... ) birth_date = models . DateField ( ... ) このとき、以下のように独自の SQL を実行できます: ... 重要ではありません。つまり、以下のクエリはどちらも同じように動作します: >>> Person . objects . raw ( "SELECT id, first_name, last_name, birth_date FROM myapp_person" ) >>> Person . objects . raw ( "SELECT last_name, birth_date, first_name, id FROM myap ... れば、簡単に Person のインスタンスにマッピングできます: >>> Person . objects . raw ( """ ... SELECT first AS first_name, ... last AS last_name, ... bd AS birth_date, ... pk AS id, ... FROM some_other_table ... """ ) ... 名称が一致している限り、そのモデ ... ... ge2 . has_previous () True >>> page2 . has_other_pages () True >>> page2 . next_page_number () Traceback (most recent call last): ... EmptyPage : That page contains no results >>> page2 . previous_page_number () 1 >>> page2 . start_index () # The 1-b ... ased index of the first item on this page 3 >>> page2 . end_index () # The 1-based index of the last item on this page 4 >>> p . page ( 0 ) Traceback (most recent call last): ... EmptyPage : That page number is less than 1 ... >>> p . page ( 3 ) Traceback (most recent call last): ... EmptyPage : That page contains no results 注釈 Paginator には、リストやタプル、 Django の QuerySet 、 count() または ... ... ge2 . has_previous () True >>> page2 . has_other_pages () True >>> page2 . next_page_number () Traceback (most recent call last): ... EmptyPage : That page contains no results >>> page2 . previous_page_number () 1 >>> page2 . start_index () # The 1-b ... ased index of the first item on this page 3 >>> page2 . end_index () # The 1-based index of the last item on this page 4 >>> p . page ( 0 ) Traceback (most recent call last): ... EmptyPage : That page number is less than 1 ... >>> p . page ( 3 ) Traceback (most recent call last): ... EmptyPage : That page contains no results 注釈 Paginator には、リストやタプル、 Django の QuerySet 、 count() または ... 2026年10月08日