2 回答

TA貢獻(xiàn)1831條經(jīng)驗 獲得超10個贊
引用sof上的一個回答。
class Test(models.Model):
charNull = models.CharField(max_length=10, null=True)
charBlank = models.CharField(max_length=10, blank=True)
charNullBlank = models.CharField(max_length=10, null=True, blank=True)
intNull = models.IntegerField(null=True)
intBlank = models.IntegerField(blank=True)
intNullBlank = models.IntegerField(null=True, blank=True)
dateNull = models.DateTimeField(null=True)
dateBlank = models.DateTimeField(blank=True)
dateNullBlank = models.DateTimeField(null=True, blank=True)
The database fields created for MySQL 5.6.x are :
CREATE TABLE test (
id INT(11) NOT NULL AUTO_INCREMENT,
`charNull` VARCHAR(10) NULL DEFAULT NULL,
`charBlank` VARCHAR(10) NOT NULL,
`charNullBlank` VARCHAR(10) NULL DEFAULT NULL,
`intNull` INT(11) NULL DEFAULT NULL,
`intBlank` INT(11) NOT NULL,
`intNullBlank` INT(11) NULL DEFAULT NULL,
`dateNull` DATETIME NULL DEFAULT NULL,
`dateBlank` DATETIME NOT NULL,
`dateNullBlank` DATETIME NULL DEFAULT NULL
)
只是從數(shù)據(jù)庫層面來說。

TA貢獻(xiàn)1775條經(jīng)驗 獲得超11個贊
null:
If True, Django will store empty values as NULL in the database. Default
is False.
如果為True,空值將會被存儲為NULL,默認(rèn)為False。
blank:
If True, the field is allowed to be blank. Default is False.
如果為True,字段允許為空,默認(rèn)不允許。
- 2 回答
- 0 關(guān)注
- 638 瀏覽
添加回答
舉報