... ngo.conf.urls.i18n import i18n_patterns from django.urls import include , path from about import views as about_views from news import views as news_views from sitemap.views import sitemap urlpatterns = [ path ( "sitemap.xml" , sitemap , name = "site ... map-xml" ), ] news_patterns = ( [ path ( "" , news_views . index , name = "index" ), path ( "category/<slug:slug>/" , news_views . category , ... name = "category" ), path ( "<slug:slug>/" , news_views . details , name = "detail" ), ], "news" , ) urlpatterns += i18n_patterns ( path ( "about/" , about_views . main , n ... ... ngo.conf.urls.i18n import i18n_patterns from django.urls import include , path from about import views as about_views from news import views as news_views from sitemap.views import sitemap urlpatterns = [ path ( "sitemap.xml" , sitemap , name = "site ... map-xml" ), ] news_patterns = ( [ path ( "" , news_views . index , name = "index" ), path ( "category/<slug:slug>/" , news_views . category , ... name = "category" ), path ( "<slug:slug>/" , news_views . details , name = "detail" ), ], "news" , ) urlpatterns += i18n_patterns ( path ( "about/" , about_views . main , n ... ... つか作ります: >>> p1 = Publication ( title = "The Python Journal" ) >>> p1 . save () >>> p2 = Publication ( title = "Science News" ) >>> p2 . save () >>> p3 = Publication ( title = "Science Weekly" ) >>> p3 . save () Article を一つ作ります: >>> a1 = Ar ... Python Journal>]> >>> a2 . publications . all () <QuerySet [<Publication: Highlights for Children>, <Publication: Science News>, <Publication: Science Weekly>, <Publication: The Python Journal>]> Publication オブジェクトはリレーション先の Article オ ... filter ( article__headline__startswith = "NASA" ) <QuerySet [<Publication: Highlights for Children>, <Publication: Science News>, <Publication: Science Weekly>, <Publication: The Python Journal>]> >>> Publication . objects . filter ( article__id = 1 ... ... つか作ります: >>> p1 = Publication ( title = "The Python Journal" ) >>> p1 . save () >>> p2 = Publication ( title = "Science News" ) >>> p2 . save () >>> p3 = Publication ( title = "Science Weekly" ) >>> p3 . save () Article を一つ作ります: >>> a1 = Ar ... Python Journal>]> >>> a2 . publications . all () <QuerySet [<Publication: Highlights for Children>, <Publication: Science News>, <Publication: Science Weekly>, <Publication: The Python Journal>]> Publication オブジェクトはリレーション先の Article オ ... filter ( article__headline__startswith = "NASA" ) <QuerySet [<Publication: Highlights for Children>, <Publication: Science News>, <Publication: Science Weekly>, <Publication: The Python Journal>]> >>> Publication . objects . filter ( article__id = 1 ... ... されています。これまでのところ、長年におけるデータベーススキーマの問題を解決してきた実績があります。 簡単な例を示しましょう: news/models.py ¶ from django.db import models class Reporter ( models . Model ): full_name = models . CharField ( max_length = ... にアクセスできます。API はオンザフライで生成され、コードを作成する必要はありません: # Import the models we created from our "news" app >>> from news.models import Article , Reporter # No reporters are in the system yet. >>> Reporter . objects . all () ... ブジェクトを追加、変更、削除できるウェブサイトを作成できます。必要なステップは、管理サイトにモデルを登録することだけです。: news/models.py ¶ from django.db import models class Article ( models . Model ): pub_date = models . DateField () headline = mod ... ... されています。これまでのところ、長年におけるデータベーススキーマの問題を解決してきた実績があります。 簡単な例を示しましょう: news/models.py ¶ from django.db import models class Reporter ( models . Model ): full_name = models . CharField ( max_length = ... にアクセスできます。API はオンザフライで生成され、コードを作成する必要はありません: # Import the models we created from our "news" app >>> from news.models import Article , Reporter # No reporters are in the system yet. >>> Reporter . objects . all () ... ブジェクトを追加、変更、削除できるウェブサイトを作成できます。必要なステップは、管理サイトにモデルを登録することだけです。: news/models.py ¶ from django.db import models class Article ( models . Model ): pub_date = models . DateField () headline = mod ... ... す。 サイトマップビューは追加の必須引数を取ります: {'sitemaps': sitemaps} . sitemaps は短いセクションラベル (例えば blog や news ) を Sitemap クラス (例えば BlogSitemap や NewsSitemap ) にマップする辞書です。また、 Sitemap クラスの インスタンス (例えば ... です。 The item attribute has been added for each URL to allow more flexible customization 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 t ... his would generate a Google News compatible sitemap: <?xml version="1.0" encoding="UTF-8"?> <urlset xmlns= "https://www.sitemaps.org/schemas/sitemap/0.9" x ... ... す。 サイトマップビューは追加の必須引数を取ります: {'sitemaps': sitemaps} . sitemaps は短いセクションラベル (例えば blog や news ) を Sitemap クラス (例えば BlogSitemap や NewsSitemap ) にマップする辞書です。また、 Sitemap クラスの インスタンス (例えば ... です。 The item attribute has been added for each URL to allow more flexible customization 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 t ... his would generate a Google News compatible sitemap: <?xml version="1.0" encoding="UTF-8"?> <urlset xmlns= "https://www.sitemaps.org/schemas/sitemap/0.9" x ... ... onf で使用される呼び出し可能なビューオブジェクトを指定できます。たとえば、下記の url が与えられている場合を考えます。 from news import views path ( "archive/" , views . archive , name = "news-archive" ) URL を逆引きするために、以下の方法を使用できます ... : # using the named URL reverse ( "news-archive" ) # passing a callable object # (This is discouraged because you can't reverse namespaced views this way.) from n ... ューオブジェクトは as_view() を呼び出した結果でもかまいません。元の例に従うと、ビューオブジェクトは次のように定義できます。 news/views.py ¶ from django.views import View class ArchiveView ( View ): ... archive = ArchiveView . as_view () ただし、名前空 ... ... onf で使用される呼び出し可能なビューオブジェクトを指定できます。たとえば、下記の url が与えられている場合を考えます。 from news import views path ( "archive/" , views . archive , name = "news-archive" ) URL を逆引きするために、以下の方法を使用できます ... : # using the named URL reverse ( "news-archive" ) # passing a callable object # (This is discouraged because you can't reverse namespaced views this way.) from n ... ューオブジェクトは as_view() を呼び出した結果でもかまいません。元の例に従うと、ビューオブジェクトは次のように定義できます。 news/views.py ¶ from django.views import View class ArchiveView ( View ): ... archive = ArchiveView . as_view () ただし、名前空 ... 2026年10月08日