From 47333f6d1e3086aa0fb7d0bddb888bea8fb76526 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Thu, 13 Apr 2006 03:46:21 +0000 Subject: [PATCH] magic-removal: Fixed #1562 -- Added null and blank detection to 'inspectdb'. Appears only to work for MySQL at this point. git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2692 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/management.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/django/core/management.py b/django/core/management.py index 1315cea036..c4ce4cbf71 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -753,6 +753,13 @@ def inspectdb(db_name): if att_name == 'id' and field_type == 'AutoField(' and extra_params == {'primary_key': True}: continue + # Add 'null' and 'blank', if the 'null_ok' flag was present in the + # table description. + if row[6]: # If it's NULL... + extra_params['blank'] = True + if not field_type in ('TextField', 'CharField'): + extra_params['null'] = True + field_desc = '%s = models.%s' % (att_name, field_type) if extra_params: if not field_desc.endswith('('):