Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

using default as none in django mdoels

>>> type('')
<class 'str'>
>>> type(None)
<class 'NoneType'>
>>>

Avoid using null on string-based fields such as CharField and TextField. 
If a string-based field has null=True, that means it has two possible values for “no data”: NULL, and the empty string. 
In most cases, it’s redundant to have two possible values for “no data;” 
the Django convention is to use the empty string, not NULL.
One exception is when a CharField has both unique=True and blank=True set. 
In this situation, null=True is required to avoid unique constraint violations when saving multiple objects with blank values.
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #default #django #mdoels
ADD COMMENT
Topic
Name
2+1 =