mirror of https://github.com/django/django.git
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:
parent
808e50986b
commit
cfbf261709
|
@ -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:
|
||||
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])
|
||||
|
|
Loading…
Reference in New Issue