... 必要になることもあります。 複合主キーを使用するには、モデルを定義する際に pk 属性を CompositePrimaryKey に設定します: class Product ( models . Model ): name = models . CharField ( max_length = 100 ) class Order ( models . Model ): reference = models . Ch ... ield ( max_length = 20 , primary_key = True ) class OrderLineItem ( models . Model ): pk = models . CompositePrimaryKey ( "product_id" , "order_id" ) product = models . ForeignKey ( Product , on_delete = models . CASCADE ) order = models . ForeignKey ( ... te = models . CASCADE ) quantity = models . IntegerField () これにより、Django はテーブル作成時に複合主キー( PRIMARY KEY (product_id, order_id) )を作成するようになります。 複合主キーは tuple (タプル)で表現されます: >>> product = Product . objects . ... ... 必要になることもあります。 複合主キーを使用するには、モデルを定義する際に pk 属性を CompositePrimaryKey に設定します: class Product ( models . Model ): name = models . CharField ( max_length = 100 ) class Order ( models . Model ): reference = models . Ch ... ield ( max_length = 20 , primary_key = True ) class OrderLineItem ( models . Model ): pk = models . CompositePrimaryKey ( "product_id" , "order_id" ) product = models . ForeignKey ( Product , on_delete = models . CASCADE ) order = models . ForeignKey ( ... te = models . CASCADE ) quantity = models . IntegerField () これにより、Django はテーブル作成時に複合主キー( PRIMARY KEY (product_id, order_id) )を作成するようになります。 複合主キーは tuple (タプル)で表現されます: >>> product = Product . objects . ... ... トしたりするような単純な計算が必要になることがあります。これを実現する1つの方法は、Pythonで次のように計算を行うことです: >>> product = Product . objects . get ( name = "Venezuelan Beaver Cheese" ) >>> product . number_sold += 1 >>> product . save () データ ... this kind of relative update. Using F() 式 , the previous example is expressed as: >>> from django.db.models import F >>> product = Product . objects . get ( name = "Venezuelan Beaver Cheese" ) >>> product . number_sold = F ( "number_sold" ) + 1 >>> pr ... たい場合に望ましいでしょう。データベースで全てのモデルフィールドを更新しないようにすると、実行速度が少し向上します。例えば: product . name = "Name changed again" product . save ( update_fields = [ "name" ]) update_fields 引数は文字列を含む任意のイテラブル ... ... トしたりするような単純な計算が必要になることがあります。これを実現する1つの方法は、Pythonで次のように計算を行うことです: >>> product = Product . objects . get ( name = "Venezuelan Beaver Cheese" ) >>> product . number_sold += 1 >>> product . save () データ ... this kind of relative update. Using F() 式 , the previous example is expressed as: >>> from django.db.models import F >>> product = Product . objects . get ( name = "Venezuelan Beaver Cheese" ) >>> product . number_sold = F ( "number_sold" ) + 1 >>> pr ... たい場合に望ましいでしょう。データベースで全てのモデルフィールドを更新しないようにすると、実行速度が少し向上します。例えば: product . name = "Name changed again" product . save ( update_fields = [ "name" ]) update_fields 引数は文字列を含む任意のイテラブル ... ... also the first release with Python 3 support ! We're labeling this support "experimental" because we don't yet consider it production-ready, but everything's in place for you to start porting your apps to Python 3. Our next release, Django 1.6, will sup ... plication will have all its dependencies satisfied under Python 3. Thus, we're recommending that Django 1.5 not be used in production under Python 3. Instead, use this opportunity to begin porting applications to Python 3. If you're an author of a plugg ... able component, we encourage you to start porting now. We plan to offer first-class, production-ready support for Python 3 in our next release, Django 1.6. Django 1.5 の新機能 ¶ Configurable User model ¶ In Django 1 ... ... also the first release with Python 3 support ! We're labeling this support "experimental" because we don't yet consider it production-ready, but everything's in place for you to start porting your apps to Python 3. Our next release, Django 1.6, will sup ... plication will have all its dependencies satisfied under Python 3. Thus, we're recommending that Django 1.5 not be used in production under Python 3. Instead, use this opportunity to begin porting applications to Python 3. If you're an author of a plugg ... able component, we encourage you to start porting now. We plan to offer first-class, production-ready support for Python 3 in our next release, Django 1.6. Django 1.5 の新機能 ¶ Configurable User model ¶ In Django 1 ... ... E ) object_id = models . PositiveIntegerField () content_object = GenericForeignKey ( "content_type" , "object_id" ) class Product ( models . Model ): name = models . CharField ( max_length = 100 ) Product の追加/変更ビューで Image インスタンスの編集や作 ... o.contrib import admin from django.contrib.contenttypes.admin import GenericTabularInline from myapp.models import Image , Product class ImageInline ( GenericTabularInline ): model = Image class ProductAdmin ( admin . ModelAdmin ): inlines = [ ImageInli ... ne , ] admin . site . register ( Product , ProductAdmin ) 詳しくは contenttypes のドキュメント を参照してください。 カスタムのバリデーションを admin に追加する ¶ T ... ... E ) object_id = models . PositiveIntegerField () content_object = GenericForeignKey ( "content_type" , "object_id" ) class Product ( models . Model ): name = models . CharField ( max_length = 100 ) Product の追加/変更ビューで Image インスタンスの編集や作 ... o.contrib import admin from django.contrib.contenttypes.admin import GenericTabularInline from myapp.models import Image , Product class ImageInline ( GenericTabularInline ): model = Image class ProductAdmin ( admin . ModelAdmin ): inlines = [ ImageInli ... ne , ] admin . site . register ( Product , ProductAdmin ) 詳しくは contenttypes のドキュメント を参照してください。 カスタムのバリデーションを admin に追加する ¶ T ... ... 。 フォームフィールドの入出力データをローカライズするには localize 引数を使います: class CashRegisterForm ( forms . Form ): product = forms . CharField () revenue = forms . DecimalField ( max_digits = 4 , decimal_places = 2 , localize = True ) Locale spe ... ... 。 フォームフィールドの入出力データをローカライズするには localize 引数を使います: class CashRegisterForm ( forms . Form ): product = forms . CharField () revenue = forms . DecimalField ( max_digits = 4 , decimal_places = 2 , localize = True ) Locale spe ... 2026年10月08日