... 利用できるように Django 3.0 で追加されたシステムチェックの設定を緩めました ( #31141 )。 テンプレートで列挙型 TextChoices 、 IntegerChoices 、そして Choices が使えるようになりました ( #31154 )。 名前付きグループが非文字列の値しか含まない場合でも max_length 属性が ... ... notate and then filter against the annotation. Enumerations for model field choices Custom enumeration types TextChoices , IntegerChoices , and Choices are now available as a way to define Field.choices . TextChoices and IntegerChoices types are provided for t ... ... .. JET_SKI = "J" ... >>> Vehicle . JET_SKI . label 'Jet Ski' 列挙値が整数である必要があるケースは非常に多いので、Django は IntegerChoices クラスを用意しています。例えば class Card ( models . Model ): class Suit ( models . IntegerChoices ): DIAMOND = 1 SPADE = ... LVER BRONZE" ) >>> MedalType . choices [('GOLD', 'Gold'), ('SILVER', 'Silver'), ('BRONZE', 'Bronze')] >>> Place = models . IntegerChoices ( "Place" , "FIRST SECOND THIRD" ) >>> Place . choices [(1, 'First'), (2, 'Second'), (3, 'Third')] もし int や str 以外の具 ... one という値を持つメンバを作成することはできません。代わりに、クラスに __empty__ 属性を設定します: class Answer ( models . IntegerChoices ): NO = 0 , _ ( "No" ) YES = 1 , _ ( "Yes" ) __empty__ = _ ( "(Unknown)" ) db_column Field. db_column このフィールドを使用 ... ... str or bytes using os.fspath() LazyObject instances which wrap a serializable value Enumeration types (e.g. TextChoices or IntegerChoices ) instances 任意の Django フィールド 任意の関数またはメソッドへのリファレンス (例: datetime.datetime.today ) (ただし、モジ ... 2026年10月08日