Django リファレンス メモ
ユーザー API
モデル API
データ フィールド
フィールド型 | Python型 | PostgreSQL型 - サイズ,範囲 | SQLite型 - サイズ,範囲 | 説明 |
---|---|---|---|---|
AutoField | int | serial - 4 バイト, 1 〜 2147483647 | integer | 主キー用の自動的インクリメント IntegerField |
BigAutoField | int | bigserial | integer | 64 ビット数値。1 ~ 9223372036854775807 の自動的インクリメント BigIntegerField |
BigIntegerField | int | bigint - 8 バイト, -9223372036854775808 〜 922337203685477 | bigint | Big Integer フィールド IntegerField を継承 |
BinaryField | str(base64) | byte - 最大1G, 可変長バイナリ | BLOB | Raw バイナリーデーターフィールド |
BooleanField | bool | boolean - 真偽 (true/false) 値 | bool | 真偽 (true/false) 値を表すフィールド |
CharField | str | varchar(%(max_length)s) - 可変長文字列 | varchar(%(max_length)s) | 文字列フィールド |
DateField | datetime | date - 4バイト, 日付 | date | 日付フィールド |
DateTimeField | datetime | timestamp with time zone − 8バイト, タイムゾーン付き年月日時分秒, 1マイクロ秒/14桁 | datetime | 日付と時刻のフィールド |
DecimalField | Decimal | numeric(%(max_digits)s, %(decimal_places)s) - 無制限, 精度無制限 | decimal | 固定精度の 10 進小数フィールド |
DurationField | timedelta | interval - 12バイト, 1マイクロ秒/14桁 | bigint | 日付や時刻の差を表すフィールド |
EmailField | str | varchar(%(max_length)s) - 可変長文字列 | e-mail アドレスフィールド CharField 継承 |
|
FileField | str | varchar(%(max_length)s) - 可変長文字列 | varchar(%(max_length)s) | ファイルアップロードフィールド Field 継承 |
FieldFile | File 継承 | |||
FilePathField | str | varchar(%(max_length)s) - 可変長文字列 | varchar(%(max_length)s) | ファイルパスフィールド |
FloatField | float | double precision - 8バイト, 浮動小数(有効桁15) | real | 浮動小数点フィールド |
ImageField | str | varchar(%(max_length)s) - 可変長文字列 | イメージフィールド FileField 継承 |
|
IntegerField | int | integer - 4 バイト, -2147483648 〜 +2147483647 | integer | 固定精度整数フィールド |
IPAddressField | str | inet - 12 or 24バイト - IPv4/IPv6アドレス | char(15) | IPv4アドレス |
GenericIPAddressField | str | inet - 12 or 24バイト - IPv4/IPv6アドレス | char(39) | IPv4/IPv6アドレス |
NullBooleanField | bool | boolean 真偽 (true/false) 値 | bool | Null と真偽 (true/false) 値を表すフィールド |
OneToOneField | int | integer | ||
PositiveIntegerField | int | integer - 4バイト, -2147483648 〜 +2147483647 | integer unsigned | 正数(0 〜 2147483647) CHECK(“%(column)s” >= 0) IntegerField を継承 |
PositiveSmallIntegerField | int | smallint - 2バイト, -32768 〜 +32767 | smallint unsigned | 正数(0 〜 32767) CHECK(“%(column)s” >= 0) IntegerField を継承 |
SlugField | str | varchar(%(max_length)s) - 可変長文字列 | varchar(%(max_length)s) | 内容を示す短いラベルフィールド |
SmallAutoField | int | integer | ||
SmallIntegerField | int | smallint - 2バイト, -32768 〜 +32767 | smallint | 固定精度整数フィールド |
TextField | str | text - 無制限, 可変長文字列 | text | 長いテキストフィールド |
TimeField | datetime | time - 8バイト, タイムゾーンなし時刻 1マイクロ秒/14桁 | time | 時刻フィールド |
URLField | str | varchar(%(max_length)s) - 可変長文字列 | varchar(%(max_length)s) | URL を表す CharField 継承 |
UUIDField | UUID | uuid - 16バイト, uuid | char(32) | ユニバーサルユニークIDフィールド(32文字) |
| | | 1.8になし TextField 継承 |
|
| | | - | 2.0で廃止 カンマで区切った整数からなるフィールド |
リレーション フィールド
フィールド型 | Python型 | PostgreSQL型 | 説明 |
---|---|---|---|
ForeignKey | int | ||
ManyToManyField | int | ||
OneToOneField(ForeignKey 継承) | int | integer |
参考文献
django/db/models/fields/__init__.py django/db/models/fields/files.py django/db/backends/postgresql_psycopg2/base.py
テンプレート API
テンプレート | Django ドキュメント | Django
組み込みタグ/フィルタリファレンス — Django 1.4 documentation
Python プログラマのための Django テンプレート言語ガイド — Django v1.4 documentation
テンプレートタグやフィルタを自作する — Django 1.4 documentation
参考文献
フォーム フィールド
フィールド型 | 説明 |
---|---|
BooleanField | |
CharField | |
ChoiceField | |
TypedChoiceField | |
DateField | |
DateTimeField | |
DecimalField | |
EmailField | |
FileField | |
FilePathField | |
FloatField | |
ImageField | |
IntegerField | |
IPAddressField | |
MultipleChoiceField | |
NullBooleanField | |
RegexField | |
TimeField | |
URLField | |
ComboField | |
MultiValueField | |
SplitDateTimeField | |
ModelChoiceField | |
ModelMultipleChoiceField |