在django中區分null = True,空白= True - differentiate null=True, blank=True in django

問題:

When we add a database field in django we generally write models.CharField(max_length=100, null=True, blank=True) . 當咱們在Django中添加數據庫字段時,一般會編寫models.CharField(max_length=100, null=True, blank=True) The same is done with ForeignKey , DecimalField etc. What is the basic difference in having ForeignKeyDecimalField等進行相同的操做。 數據庫

  1. null=True only null=Truenull=True
  2. blank=True only blank=Trueblank=True
  3. null=True , blank=True null=Trueblank=True

in respect to different ( CharField , ForeignKey , ManyToManyField , DateTimeField ) fields. 關於不一樣的字段( CharFieldForeignKeyManyToManyFieldDateTimeField )。 What are the advantages/disadvantages of using 1/2/3? 使用1/2/3有哪些優勢/缺點? django


解決方案:

參考一: https://stackoom.com/question/a7dw/在django中區分null-True-空白-True
參考二: https://oldbug.net/q/a7dw/differentiate-null-True-blank-True-in-django