... に掲載することができ、一つの Publication は複数の Article オブジェクトを持ちます: from django.db import models class Publication ( models . Model ): title = models ... __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 . hea ... dline 以下は、Python API の機能を使って実行できる操作の例です。 Publication インスタンスをいくつか作ります: >>> p1 = Publication ( title = "The Python Journal" ) >>> p1 . save () >>> p2 = Publicatio ... ... に掲載することができ、一つの Publication は複数の Article オブジェクトを持ちます: from django.db import models class Publication ( models . Model ): title = models ... __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 . hea ... dline 以下は、Python API の機能を使って実行できる操作の例です。 Publication インスタンスをいくつか作ります: >>> p1 = Publication ( title = "The Python Journal" ) >>> p1 . save () >>> p2 = Publicatio ... ... の順序を指定する式 (または文字列や式のタプルやリスト) のオプションの文字列。 ArrayAgg.order_by と同じ例です。 使用例: class Publication ( models . Model ): title = models . CharField ( max_length = 30 ) class Article ( models . Model ): headline = models . C ... harField ( max_length = 100 ) publications = models . ManyToManyField ( Publication ) >>> article = Article . objects . create ( headline = "NASA uses Python" ) >>> ... article . publications . create ( title = "The Python Journal" ) <Publication: Publication object (1)> >>> article . publications . create ( tit ... ... の順序を指定する式 (または文字列や式のタプルやリスト) のオプションの文字列。 ArrayAgg.order_by と同じ例です。 使用例: class Publication ( models . Model ): title = models . CharField ( max_length = 30 ) class Article ( models . Model ): headline = models . C ... harField ( max_length = 100 ) publications = models . ManyToManyField ( Publication ) >>> article = Article . objects . create ( headline = "NASA uses Python" ) >>> ... article . publications . create ( title = "The Python Journal" ) <Publication: Publication object (1)> >>> article . publications . create ( tit ... ... ustomization of the templates, such as Google news sitemaps . Assuming Sitemap's items() would return a list of items with publication_data and a tags field something like this would generate a Google News compatible sitemap: <?xml version="1.0" encoding="U ... gefreq> {% endif %} {% if url.priority %} <priority> {{ url.priority }} </priority> {% endif %} <news:news> {% if url.item.publication_date %} <news:publication_date> {{ url.item.publication_date | date :"Y-m-d" }} </news:publication_date> {% endif %} {% if ... ... ustomization of the templates, such as Google news sitemaps . Assuming Sitemap's items() would return a list of items with publication_data and a tags field something like this would generate a Google News compatible sitemap: <?xml version="1.0" encoding="U ... gefreq> {% endif %} {% if url.priority %} <priority> {{ url.priority }} </priority> {% endif %} <news:news> {% if url.item.publication_date %} <news:publication_date> {{ url.item.publication_date | date :"Y-m-d" }} </news:publication_date> {% endif %} {% if ... ... ListView ( ListView ): model = Book def head ( self , * args , ** kwargs ): last_book = self . get_queryset () . latest ( "publication_date" ) response = HttpResponse ( # RFC 1123 date format. headers = { "Last-Modified" : last_book . publication_date . str ... ... ListView ( ListView ): model = Book def head ( self , * args , ** kwargs ): last_book = self . get_queryset () . latest ( "publication_date" ) response = HttpResponse ( # RFC 1123 date format. headers = { "Last-Modified" : last_book . publication_date . str ... ... e. if self . status == "draft" and self . pub_date is not None : raise ValidationError ( _ ( "Draft entries may not have a publication date." )) # Set the pub_date for published items if it hasn't been set already. if self . status == "published" and self . ... atus == "draft" and self . pub_date is not None : raise ValidationError ( { "pub_date" : _ ( "Draft entries may not have a publication date." )} ) ... Model.clean() 実施中に複数フィールドでエラーを発見した場合、ディクショナリを渡してエラーにフィールド名をマ ... lf . pub_date is not None : if exclude and "status" in exclude : raise ValidationError ( _ ( "Draft entries may not have a publication date." ) ) else : raise ValidationError ( { "status" : _ ( "Set status to draft if there is not a publication date." ), } ... ... e. if self . status == "draft" and self . pub_date is not None : raise ValidationError ( _ ( "Draft entries may not have a publication date." )) # Set the pub_date for published items if it hasn't been set already. if self . status == "published" and self . ... atus == "draft" and self . pub_date is not None : raise ValidationError ( { "pub_date" : _ ( "Draft entries may not have a publication date." )} ) ... Model.clean() 実施中に複数フィールドでエラーを発見した場合、ディクショナリを渡してエラーにフィールド名をマ ... lf . pub_date is not None : if exclude and "status" in exclude : raise ValidationError ( _ ( "Draft entries may not have a publication date." ) ) else : raise ValidationError ( { "status" : _ ( "Set status to draft if there is not a publication date." ), } ... 2026年10月08日