... postgres.forms import SimpleArrayField >>> class NumberListForm ( forms . Form ): ... numbers = SimpleArrayField ( forms . IntegerField ()) ... >>> form = NumberListForm ({ "numbers" : "1,2,3" }) >>> form . is_valid () True >>> form . cleaned_data {'numbers' ... gres.forms import SimpleArrayField >>> class GridForm ( forms . Form ): ... places = SimpleArrayField ( SimpleArrayField ( IntegerField ()), delimiter = "|" ) ... >>> form = GridForm ({ "places" : "1,2|2,1|4,3" }) >>> form . is_valid () True >>> form . clean ... で、かつ remove_trailing_nulls が True の場合、末尾にのみ null 値が許され、その値は取り除かれます。 例: SplitArrayField ( IntegerField ( required = True ), size = 3 , remove_trailing_nulls = False ) [ "1" , "2" , "3" ] # -> [1, 2, 3] [ "1" , "2" , "" ] # -> ... ... sponding to the attributes in the # world borders shapefile. name = models . CharField ( max_length = 50 ) area = models . IntegerField () pop2005 = models . IntegerField ( "Population 2005" ) fips = models . CharField ( "FIPS Code" , max_length = 2 , null = ... . CharField ( "2 Digit ISO" , max_length = 2 ) iso3 = models . CharField ( "3 Digit ISO" , max_length = 3 ) un = models . IntegerField ( "United Nations Code" ) region = models . IntegerField ( "Region Code" ) subregion = models . IntegerField ( "Sub-Region ... ( max_length = 2 ) iso2 = models . CharField ( max_length = 2 ) iso3 = models . CharField ( max_length = 3 ) un = models . IntegerField () name = models . CharField ( max_length = 50 ) area = models . IntegerField () pop2005 = models . IntegerField () region ... ... models class TenantUser ( models . Model ): pk = models . CompositePrimaryKey ( "tenant_id" , "id" ) tenant_id = models . IntegerField () id = models . IntegerField () >>> TenantUser . _meta . pk_fields [ <django.db.models.fields.IntegerField: tenant_id>, < ... django.db.models.fields.IntegerField: id> ] Otherwise it will contain the single field declared as the primary key of the model, either explicitly with primary ... ... モデルフィールド フォームフィールド AutoField フォーム上では表示されません。 BigAutoField フォーム上では表示されません。 BigIntegerField IntegerField で min_value が -9223372036854775808 から max_value に 9223372036854775807 セットされます。 BinaryField edita ... FileField FilePathField FilePathField FloatField FloatField ForeignKey ModelChoiceField (see below) ImageField ImageField IntegerField IntegerField IPAddressField IPAddressField GenericIPAddressField GenericIPAddressField JSONField JSONField ManyToManyField ... ModelMultipleChoiceField (以下を参照) PositiveBigIntegerField IntegerField PositiveIntegerField IntegerField PositiveSmallIntegerField IntegerField SlugField SlugField SmallAutoField フ ... ... han generating a bad request response ( #27820 ). Fixed a crash on Oracle and PostgreSQL when subtracting DurationField or IntegerField from DateField ( #27828 ). Fixed query expression date subtraction accuracy on PostgreSQL for differences larger than a mo ... ... 使用例: class Comment ( models . Model ): body = models . TextField () published = models . BooleanField () rank = models . IntegerField () >>> from django.db.models import Q >>> from django.contrib.postgres.aggregates import BoolAnd >>> Comment . objects . a ... 使用例: class Comment ( models . Model ): body = models . TextField () published = models . BooleanField () rank = models . IntegerField () >>> from django.db.models import Q >>> from django.contrib.postgres.aggregates import BoolOr >>> Comment . objects . ag ... または式のタプルもしくはリスト)。 ArrayAgg.order_by と同じ例です。 使用例: class Room ( models . Model ): number = models . IntegerField ( unique = True ) class HotelReservation ( models . Model ): room = models . ForeignKey ( "Room" , on_delete = models . CA ... ... 数です。 配列のベースとなるデータ型や動作を指定します。これは、 Field のサブクラスのインスタンスである必要があります。例えば IntegerField や CharField などが考えられます。ほとんどのフィールドタイプが許容されますが、リレーショナルデータを処理するもの ( ForeignK ... import ArrayField from django.db import models class Board ( models . Model ): pieces = ArrayField ( ArrayField ( models . IntegerField ())) # Valid Board ( pieces = [ [ 2 , 3 ], [ 2 , 1 ], ] ) # Not valid Board ( pieces = [ [ 2 , 3 ], [ 2 ], ] ) 不規則な形状 ... [<Post: First post>, <Post: Second post>, <Post: Third post>]> len 配列の長さを返します。この後に利用可能なルックアップは IntegerField で利用可能なものです。たとえば: >>> Post . objects . create ( name = "First post" , tags = [ "thoughts" , "django" ]) >>> ... ... Card ( models . Model ): class Suit ( models . IntegerChoices ): DIAMOND = 1 SPADE = 2 HEART = 3 CLUB = 4 suit = models . IntegerField ( choices = Suit ) また、 Enum Functional API を利用することもできます。この場合、ラベルは上記のように自動的に生成されます ... , ) ) データベースのデフォルトは、他のフィールドやモデルを参照することはできません。例えば、これは無効です: end = models . IntegerField ( db_default = F ( "start" ) + 50 ) もし db_default と Field.default の両方が指定された場合、Python コードでインスタンスを ... ださい。 フィールドの型 AutoField class AutoField ( ** options ) [ソース] 利用可能な ID に応じて、自動的にインクリメントする IntegerField です。通常は直接使う必要はありません; 指定しない場合は、主キーのフィールドが自動的にモデルに追加されます。 自動インクリメン ... ... wing are not valid : class Parent ( models . Model ): name = models . CharField ( max_length = 10 ) other_value = models . IntegerField ( unique = True ) class Child ( Parent ): father = models . OneToOneField ( Parent , primary_key = True , to_field = "othe ... r_value" , parent_link = True ) value = models . IntegerField () This bug will be fixed in the next release of Django. Caveats with support of certain databases Django attempts to supp ... ... o in the name of the strictly_above PostGIS lookup ( #25592 ). Fixed crash with contrib.postgres.forms.SplitArrayField and IntegerField on invalid value ( #25597 ). Added a helpful error message when Django and South migrations exist in the same directory ( ... 2026年10月08日