... .db import models class Publication ( models . Model ): title = models . CharField ( max_length = 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 . 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 ... ... 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 ... ... 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." ), } ... ... thors = models . ManyToManyField ( "Author" ) publisher = models . ForeignKey ( Publisher , on_delete = models . CASCADE ) publication_date = models . DateField () 次に、ビューを定義しましょう。 # views.py from django.views.generic import ListView from book ... ic import ListView from books.models import Book class BookListView ( ListView ): queryset = Book . objects . order_by ( "-publication_date" ) context_object_name = "book_list" これは小さな例ですが、queryset の概念は上手く表現できていると思います。普通はただ ... ... tps://www.djangoproject.com/ を使用してください。 名称が必要なら、何も加えずただ "Django" を使ってください。 If you need a publication date, use the year of release of the version you're referencing (e.g., 2013 for v1.5). Django のリソースはどこに行けばもっ ... ... ng, use the checklists app in the project admin . This populates a lot of boilerplate you will need for announcements, CVE publication, and hashes for commit messages. By using this app for preparing security issue metadata, your peer releasers can check yo ... ... ルごとに admin クラスを作成して、 admin.site.register() の 2 番目の引数に渡すと いうパターンに従ってください。 上の例では、「Publication date」フィールドの表示位置を「Question」フィールドよりも前に変更しています: 二つしかフィールドがないので、あまりぱっとした ... 2026年10月08日