[patch] Inspectdb generates CharFields with null
|Reported by:||Owned by:||Adrian Holovaty|
|Component:||Database layer (models, ORM)||Version:||master|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Inspectdb generates CharFields with null=true for mysql tables that have attributes which allow Null values. This is not Django convention:
If True, Django will store empty values as NULL in the database. Default is False.
Note that empty string values will always get stored as empty strings, not as NULL -- so use null=True for non-string fields such as integers, booleans and dates.
Avoid using null on string-based fields such as CharField and TextField unless you have an excellent reason. 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;" Django convention is to use the empty string, not NULL."
Change History (4)
comment:1 Changed 10 years ago by
|Summary:||Inspectdb generates CharFields with null=true while this is not Django convention → [patch] Inspectdb generates CharFields with null=true while this is not Django convention|
|Version:||magic-removal → SVN|