How to set NULL for IntegerField instead of setting 0?

后端 未结 1 1459
萌比男神i
萌比男神i 2021-02-12 11:09

I\'m uploading some data from an excel file using xlrd and turning that data into models (with mainly IntegerField values) in Django. My excel file has a bunch of missing data.

1条回答
  •  梦谈多话
    2021-02-12 11:35

    Instead of using

    age = models.IntegerField()
    

    use

    age = models.IntegerField(blank=True, null=True)
    

    When we specify

    blank=True, null=True
    

    it will allow you to store null in that column

    0 讨论(0)
提交回复
热议问题