... I の機能を使って実行できる操作の例です。 複数の Reporter を作成する: >>> r = Reporter ( first_name = "John" , last_name = "Smith" , email = "john@example.com" ) >>> r . save () >>> r2 = Reporter ( first_name = "Paul" , last_name = "Jones" , email = "p ... pub_date = date ( 2005 , 7 , 27 ), reporter = r ) >>> a . save () >>> a . reporter . id 1 >>> a . reporter <Reporter: John Smith> オブジェクトを外部キーリレーションシップに代入する前に保存する必要があることに注意してください。たとえば、保存されていない ... orter で Article を作成すると、次のように ValueError が発生します。 >>> r3 = Reporter ( first_name = "John" , last_name = "Smith" , email = "john@example.com" ) >>> Article . objects . create ( ... headline = "This is a test" , pub_date = date ( 2005 ... ... I の機能を使って実行できる操作の例です。 複数の Reporter を作成する: >>> r = Reporter ( first_name = "John" , last_name = "Smith" , email = "john@example.com" ) >>> r . save () >>> r2 = Reporter ( first_name = "Paul" , last_name = "Jones" , email = "p ... pub_date = date ( 2005 , 7 , 27 ), reporter = r ) >>> a . save () >>> a . reporter . id 1 >>> a . reporter <Reporter: John Smith> オブジェクトを外部キーリレーションシップに代入する前に保存する必要があることに注意してください。たとえば、保存されていない ... orter で Article を作成すると、次のように ValueError が発生します。 >>> r3 = Reporter ( first_name = "John" , last_name = "Smith" , email = "john@example.com" ) >>> Article . objects . create ( ... headline = "This is a test" , pub_date = date ( 2005 ... ... ort FloatField >>> from django.db.models.functions import Cast >>> Author . objects . create ( age = 25 , name = "Margaret Smith" ) >>> author = Author . objects . annotate ( ... age_as_float = Cast ( "age" , output_field = FloatField ()), ... ) . get ... .db.models import Sum >>> from django.db.models.functions import Coalesce >>> Author . objects . create ( name = "Margaret Smith" , goes_by = "Maggie" ) >>> author = Author . objects . annotate ( screen_name = Coalesce ( "alias" , "goes_by" , "name" ) ... els import F >>> from django.db.models.functions import JSONArray , Lower >>> Author . objects . create ( name = "Margaret Smith" , alias = "msmith" , age = 25 ) >>> author = Author . objects . annotate ( ... json_array = JSONArray ( ... Lower ( "name ... ... ort FloatField >>> from django.db.models.functions import Cast >>> Author . objects . create ( age = 25 , name = "Margaret Smith" ) >>> author = Author . objects . annotate ( ... age_as_float = Cast ( "age" , output_field = FloatField ()), ... ) . get ... .db.models import Sum >>> from django.db.models.functions import Coalesce >>> Author . objects . create ( name = "Margaret Smith" , goes_by = "Maggie" ) >>> author = Author . objects . annotate ( screen_name = Coalesce ( "alias" , "goes_by" , "name" ) ... els import F >>> from django.db.models.functions import JSONArray , Lower >>> Author . objects . create ( name = "Margaret Smith" , alias = "msmith" , age = 25 ) >>> author = Author . objects . annotate ( ... json_array = JSONArray ( ... Lower ( "name ... ... he system yet. >>> Reporter . objects . all () <QuerySet []> # Create a new Reporter. >>> r = Reporter ( full_name = "John Smith" ) # Save the object into the database. You have to call save() explicitly. >>> r . save () # Now it has an ID. >>> r . id ... 1 # Now the new reporter is in the database. >>> Reporter . objects . all () <QuerySet [<Reporter: John Smith>]> # Fields are represented as attributes on the Python object. >>> r . full_name 'John Smith' # Django provides a rich da ... tabase lookup API. >>> Reporter . objects . get ( id = 1 ) <Reporter: John Smith> >>> Reporter . objects . get ( full_name__startswith = "John" ) <Reporter: John Smith> >>> Reporter . objects . get ( ful ... ... he system yet. >>> Reporter . objects . all () <QuerySet []> # Create a new Reporter. >>> r = Reporter ( full_name = "John Smith" ) # Save the object into the database. You have to call save() explicitly. >>> r . save () # Now it has an ID. >>> r . id ... 1 # Now the new reporter is in the database. >>> Reporter . objects . all () <QuerySet [<Reporter: John Smith>]> # Fields are represented as attributes on the Python object. >>> r . full_name 'John Smith' # Django provides a rich da ... tabase lookup API. >>> Reporter . objects . get ( id = 1 ) <Reporter: John Smith> >>> Reporter . objects . get ( full_name__startswith = "John" ) <Reporter: John Smith> >>> Reporter . objects . get ( ful ... ... R , ... registered_on = date . today () - timedelta ( days = 36 ), ... ) >>> Client . objects . create ( ... name = "James Smith" , ... account_type = Client . GOLD , ... registered_on = date . today () - timedelta ( days = 5 ), ... ) >>> Client . obj ... ), ... default = Value ( "0%" ), ... ), ... ) . values_list ( "name" , "discount" ) <QuerySet [('Jane Doe', '0%'), ('James Smith', '5%'), ('Jack Black', '10%')]> Case() は任意の数の When() オブジェクトを引数として受け取ることができます。その他のオプシ ... )), ... default = Value ( "0%" ), ... ) ... ) . values_list ( "name" , "discount" ) <QuerySet [('Jane Doe', '5%'), ('James Smith', '0%'), ('Jack Black', '10%')]> 注釈 条件は順番に評価されるので、上の例では2番目の条件がJane DoeとJack Blackの両方にマッチ ... ... R , ... registered_on = date . today () - timedelta ( days = 36 ), ... ) >>> Client . objects . create ( ... name = "James Smith" , ... account_type = Client . GOLD , ... registered_on = date . today () - timedelta ( days = 5 ), ... ) >>> Client . obj ... ), ... default = Value ( "0%" ), ... ), ... ) . values_list ( "name" , "discount" ) <QuerySet [('Jane Doe', '0%'), ('James Smith', '5%'), ('Jack Black', '10%')]> Case() は任意の数の When() オブジェクトを引数として受け取ることができます。その他のオプシ ... )), ... default = Value ( "0%" ), ... ) ... ) . values_list ( "name" , "discount" ) <QuerySet [('Jane Doe', '5%'), ('James Smith', '0%'), ('Jack Black', '10%')]> 注釈 条件は順番に評価されるので、上の例では2番目の条件がJane DoeとJack Blackの両方にマッチ ... ... ng. """ def author_name ( self ): """ Returns the feed's author's name as a normal Python string. """ author_name = "Sally Smith" # Hard-coded author name. # AUTHOR EMAIL --One of the following three is optional. The framework # looks for them in this ... self ): """ Returns the feed's copyright notice as a normal Python string. """ feed_copyright = "Copyright (c) 2007, Sally Smith" # Hard-coded copyright notice. # TTL -- One of the following three is optional. The framework looks # for them in this or ... . """ def item_author_name ( self ): """ Returns the author name for every item in the feed. """ item_author_name = "Sally Smith" # Hard-coded author name. # ITEM AUTHOR EMAIL --One of the following three is optional. The # framework looks for them in ... ... ng. """ def author_name ( self ): """ Returns the feed's author's name as a normal Python string. """ author_name = "Sally Smith" # Hard-coded author name. # AUTHOR EMAIL --One of the following three is optional. The framework # looks for them in this ... self ): """ Returns the feed's copyright notice as a normal Python string. """ feed_copyright = "Copyright (c) 2007, Sally Smith" # Hard-coded copyright notice. # TTL -- One of the following three is optional. The framework looks # for them in this or ... . """ def item_author_name ( self ): """ Returns the author name for every item in the feed. """ item_author_name = "Sally Smith" # Hard-coded author name. # ITEM AUTHOR EMAIL --One of the following three is optional. The # framework looks for them in ... 2026年10月08日