From cfbf261709ffde0419a8aa75319e2f4ae4c29619 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Thu, 4 Aug 2005 03:49:24 +0000 Subject: [PATCH] Improved 'django-admin inspectdb' so that it doesn't raise an exception for unknown field types. Now it uses TextField by default and outputs a Python comment. git-svn-id: http://code.djangoproject.com/svn/django/trunk@398 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/management.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/django/core/management.py b/django/core/management.py index 4def37e0b9..9e8abb4614 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -464,7 +464,12 @@ def inspectdb(db_name): rel_to = rel[1] == table_name and "'self'" or table2model(rel[1]) field_desc = 'meta.ForeignKey(%s, name=%r' % (rel_to, row[0]) else: - field_type = db.DATA_TYPES_REVERSE[row[1]] + try: + field_type = db.DATA_TYPES_REVERSE[row[1]] + except KeyError: + field_type = 'TextField' + yield " # The model-creator script used TextField by default, because" + yield " # it couldn't recognize your field type." field_desc = 'meta.%s(%r' % (field_type, row[0]) if field_type == 'CharField': field_desc += ', maxlength=%s' % (row[3])