diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2005-08-04 03:49:24 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2005-08-04 03:49:24 +0000 |
| commit | cfbf261709ffde0419a8aa75319e2f4ae4c29619 (patch) | |
| tree | ab6a7e65924259910a55fd946ca12161deab56b4 | |
| parent | 808e50986b0c117541b563cec055dba2937ed453 (diff) | |
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
| -rw-r--r-- | django/core/management.py | 7 |
1 files changed, 6 insertions, 1 deletions
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]) |
