Django

Code

Ticket #1819 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

[patch] Inspectdb generates CharFields with null

Reported by: remco@diji.biz Assigned to: adrian
Milestone: Component: Database layer (models, ORM)
Version: SVN Keywords:
Cc: mir@noris.de Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

textfield_null.diff (476 bytes) - added by mir@noris.de on 05/09/06 09:05:50.
patch

Change History

05/09/06 09:04:48 changed by mir@noris.de

  • cc set to mir@noris.de.
  • version changed from magic-removal to SVN.
  • summary changed from Inspectdb generates CharFields with null=true while this is not Django convention to [patch] Inspectdb generates CharFields with null=true while this is not Django convention.

Yes, you're right. Here's a patch, worked for me. Can you check it?

05/09/06 09:05:50 changed by mir@noris.de

  • attachment textfield_null.diff added.

patch

05/09/06 10:36:15 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

(In [2872]) Fixed #1819 -- inspectdb no longer puts null=True for TextField? and CharField?. Thanks, mir@noris.de

06/12/06 05:28:08 changed by Go

  • type deleted.
  • summary changed from [patch] Inspectdb generates CharFields with null=true while this is not Django convention to [patch] Inspectdb generates CharFields with null.

Add/Change #1819 ([patch] Inspectdb generates CharFields with null)




Change Properties
Action