In Django 1.9, what's the convention for using JSONField (native postgres jsonb)?

后端 未结 2 1375
南旧
南旧 2021-01-03 19:41

Django highly suggests not to use null=True for CharField and TextField string-based fields in order not to have two possible values for \"no d

2条回答
  •  囚心锁ツ
    2021-01-03 20:04

    Just wanted to add that you should avoid setting default values on JSONField. I just made a schoolboy error by setting it to {}. The result is that new objects will receive the last object's value if it was not explicitly set. Its a Python behaviour inherent in the JSONField, which I forgot to consider.

提交回复
热议问题