5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

DjangoのModelのFieldカスタマイズいろいろ

Last updated at Posted at 2014-02-10

■文字列Char

title = models.CharField(max_length=200)

■文字列Text

body = models.TextField()

■DateTime & 初期値設定

pub_date = models.DateTimeField('date published',default=datetime.datetime.now() )

■Int & リスト選択

CategoryChoices = (
    (1, 'DESIGN'),
    (2, 'TECH'),
    (3, 'ENTERTAINMENT'),
    (4, 'SOCIAL'),
    (5, 'BUSINESS'),
    (6, 'TRAVEL'),
)

category = models.IntegerField(choices=CategoryChoices)
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?