... います: from django.contrib.syndication.views import Feed from django.urls import reverse from policebeat.models import NewsItem class LatestEntriesFeed ( Feed ): title = "Police beat site news" link = "/sitenews/" description = "Updates on changes an ... d additions to police beat central." def items ( self ): return NewsItem . objects . order_by ( "-pub_date" )[: 5 ] def item_title ( self , item ): return item . title ... def item_description ( self , item ): return item . description # item_link is only needed if NewsItem has no get_absolute_url meth ... ... います: from django.contrib.syndication.views import Feed from django.urls import reverse from policebeat.models import NewsItem class LatestEntriesFeed ( Feed ): title = "Police beat site news" link = "/sitenews/" description = "Updates on changes an ... d additions to police beat central." def items ( self ): return NewsItem . objects . order_by ( "-pub_date" )[: 5 ] def item_title ( self , item ): return item . title ... def item_description ( self , item ): return item . description # item_link is only needed if NewsItem has no get_absolute_url meth ... ... 0 ) class Order ( models . Model ): reference = models . CharField ( max_length = 20 , primary_key = True ) class OrderLineItem ( models . Model ): pk = models . CompositePrimaryKey ( "product_id" , "order_id" ) product = models . ForeignKey ( Produc ... > product = Product . objects . create ( name = "apple" ) >>> order = Order . objects . create ( reference = "A755H" ) >>> item = OrderLineItem . objects . create ( product = product , order = order , quantity = 1 ) >>> item . pk (1, "A755H") pk 属性 ... に tuple を代入することで、対応するフィールドの値をまとめて設定できます: >>> item = OrderLineItem ( pk = ( 2 , "B142C" )) >>> item . pk (2, "B142C") >>> item . product_id 2 >>> item . order_id "B142C" 複合 ... ... 0 ) class Order ( models . Model ): reference = models . CharField ( max_length = 20 , primary_key = True ) class OrderLineItem ( models . Model ): pk = models . CompositePrimaryKey ( "product_id" , "order_id" ) product = models . ForeignKey ( Produc ... > product = Product . objects . create ( name = "apple" ) >>> order = Order . objects . create ( reference = "A755H" ) >>> item = OrderLineItem . objects . create ( product = product , order = order , quantity = 1 ) >>> item . pk (1, "A755H") pk 属性 ... に tuple を代入することで、対応するフィールドの値をまとめて設定できます: >>> item = OrderLineItem ( pk = ( 2 , "B142C" )) >>> item . pk (2, "B142C") >>> item . product_id 2 >>> item . order_id "B142C" 複合 ... ... してください: from django.contrib.gis.feeds import Feed class MyFeed ( Feed ): # First, as a class attribute. geometry = ... item_geometry = ... # Also a function with no arguments def geometry ( self ): ... def item_geometry ( self ): ... # And as a f ... unction with a single argument def geometry ( self , obj ): ... def item_geometry ( self , item ): ... geometry ( obj ) ¶ get_object() で返されたオブジェクトを受け取り、 feed のジオメトリを返しま ... obj ): # Can also return: `obj.poly`, and `obj.poly.centroid`. return obj . poly . extent # tuple like: (X0, Y0, X1, Y1). item_geometry ( item ) ¶ これをセットすると、フィードの各 アイテム のジオメトリを返します。これは GEOSGeometry のインスタンス、 ... ... してください: from django.contrib.gis.feeds import Feed class MyFeed ( Feed ): # First, as a class attribute. geometry = ... item_geometry = ... # Also a function with no arguments def geometry ( self ): ... def item_geometry ( self ): ... # And as a f ... unction with a single argument def geometry ( self , obj ): ... def item_geometry ( self , item ): ... geometry ( obj ) ¶ get_object() で返されたオブジェクトを受け取り、 feed のジオメトリを返しま ... obj ): # Can also return: `obj.poly`, and `obj.poly.centroid`. return obj . poly . extent # tuple like: (X0, Y0, X1, Y1). item_geometry ( item ) ¶ これをセットすると、フィードの各 アイテム のジオメトリを返します。これは GEOSGeometry のインスタンス、 ... ... の作成を自動化します。 これは Django の 配信 (syndication) フレームワーク のように動作します。サイトマップを作成するには、 Sitemap クラスを書き、 URLconf の中でそれを指定します。 インストール ¶ サイトマップ アプリをインストールするには、以下の手順に従 ... ってください。 'django.contrib.sitemaps' を INSTALLED_APPS 設定に追加します。 TEMPLATES 設定には、 DjangoTemplates バックエンドが含まれており、 APP_DIRS オプシ ... 要があるのは、 Loader() テンプレートローダーがデフォルトのテンプレートを見つけられるようにするためです)。 初期設定 ¶ views. sitemap ( request , sitemaps , section = None , template_name = 'sitemap.xml' , content_type = 'application/xml' ) ¶ Django サイ ... ... の作成を自動化します。 これは Django の 配信 (syndication) フレームワーク のように動作します。サイトマップを作成するには、 Sitemap クラスを書き、 URLconf の中でそれを指定します。 インストール ¶ サイトマップ アプリをインストールするには、以下の手順に従 ... ってください。 'django.contrib.sitemaps' を INSTALLED_APPS 設定に追加します。 TEMPLATES 設定には、 DjangoTemplates バックエンドが含まれており、 APP_DIRS オプシ ... 要があるのは、 Loader() テンプレートローダーがデフォルトのテンプレートを見つけられるようにするためです)。 初期設定 ¶ views. sitemap ( request , sitemaps , section = None , template_name = 'sitemap.xml' , content_type = 'application/xml' ) ¶ Django サイ ... ... = "A group blog by the sharpest minds in online media/journalism/publishing." , ... language = "en" , ... ) >>> feed . add_item ( ... title = "Hello" , ... link = "https://www.holovaty.com/test/" , ... description = "Testing." , ... ) >>> with open ( ... であるべきです。 stylesheets には、文字列または Stylesheet インスタンスのいずれかのシーケンスを指定する必要があります。 add_item ( title , link , description , author_email = None , author_name = None , author_link = None , pubdate = None , comments = ... None , unique_id = None , categories = () , item_copyright = None , ttl = None , updateddate = None , enclosures = None , ** kwargs ) [ソース] ¶ フィードにアイテムを追加し ... ... = "A group blog by the sharpest minds in online media/journalism/publishing." , ... language = "en" , ... ) >>> feed . add_item ( ... title = "Hello" , ... link = "https://www.holovaty.com/test/" , ... description = "Testing." , ... ) >>> with open ( ... であるべきです。 stylesheets には、文字列または Stylesheet インスタンスのいずれかのシーケンスを指定する必要があります。 add_item ( title , link , description , author_email = None , author_name = None , author_link = None , pubdate = None , comments = ... None , unique_id = None , categories = () , item_copyright = None , ttl = None , updateddate = None , enclosures = None , ** kwargs ) [ソース] ¶ フィードにアイテムを追加し ... 2026年10月08日