1
0
mirror of https://github.com/django/django.git synced 2024-12-23 09:36:06 +00:00

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
This commit is contained in:
Adrian Holovaty 2005-08-04 03:49:24 +00:00
parent 808e50986b
commit cfbf261709

View File

@ -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])