Django Model Field Customization Various

■ Character string Char

title = models.CharField(max_length=200)

■ String Text

body = models.TextField()

■ DateTime & initial value setting

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

■ Int & list selection

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

category = models.IntegerField(choices=CategoryChoices)

Recommended Posts

Django Model Field Customization Various
Django model: ManyToManyField
Model changes in Django
High Performance Django --Model
The story of a Django model field disappearing from a class
Use django model from interpreter
Django admin screen list_filter customization
Django Model with left outer join
Automatically generate model relationships with Django
Django admin screen customization first step