#1819 closed (fixed)
[patch] Inspectdb generates CharFields with null
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | minor | Keywords: | |
Cc: | mir@… | Triage Stage: | Unreviewed |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Inspectdb generates CharFields with null=true for mysql tables that have attributes which allow Null values. This is not Django convention:
"null
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."
-- source: http://www.djangoproject.com/documentation/model_api/
Attachments (1)
Change History (4)
comment:1 by , 19 years ago
Cc: | added |
---|---|
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 |
comment:2 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:3 by , 19 years ago
Summary: | [patch] Inspectdb generates CharFields with null=true while this is not Django convention → [patch] Inspectdb generates CharFields with null |
---|---|
Type: | defect |
Yes, you're right. Here's a patch, worked for me. Can you check it?