Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improved 'django-admin inspectdb' so that it doesn't raise an excepti…

…on 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
  • Loading branch information...
commit cfbf261709ffde0419a8aa75319e2f4ae4c29619 1 parent 808e509
Adrian Holovaty adrianholovaty authored
Showing with 6 additions and 1 deletion.
  1. +6 −1 django/core/management.py
7 django/core/management.py
View
@@ -464,7 +464,12 @@ def table2model(table_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])
Please sign in to comment.
Something went wrong with that request. Please try again.