diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2006-02-04 20:08:30 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2006-02-04 20:08:30 +0000 |
| commit | 9423c4e4a886b373243811e08a40a031ae484772 (patch) | |
| tree | 053c2cc5b44a23b31e61111c224cd398724abd07 /docs | |
| parent | ee484f1c483d103a56b3d4cf43d929eaa890811b (diff) | |
Fixed #1328 -- Improved 'inspectdb' to handle Python reserved words as field names. Also updated docs.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@2271 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/django-admin.txt | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/docs/django-admin.txt b/docs/django-admin.txt index 750bb58970..36ebe8ba67 100644 --- a/docs/django-admin.txt +++ b/docs/django-admin.txt @@ -92,6 +92,24 @@ Use this if you have a legacy database with which you'd like to use Django. The script will inspect the database and create a model for each table within it. +As you might expect, the created models will have an attribute for every field +in the table. Note that ``inspectdb`` has a few special cases in its field-name +output: + + * If ``inspectdb`` cannot map a column's type to a model field type, it'll + use ``TextField`` and will insert the Python comment + ``'This field type is a guess.'`` next to the field in the generated + model. + + * **New in Django development version.** If the database column name is a + Python reserved word (such as ``'pass'``, ``'class'`` or ``'for'``), + ``inspectdb`` will append ``'_field'`` to the attribute name. For + example, if a table has a column ``'for'``, the generated model will have + a field ``'for_field'``, with the ``db_column`` attribute set to + ``'for'``. ``inspectdb`` will insert the Python comment + ``'Field renamed because it was a Python reserved word.'`` next to the + field. + This feature is meant as a shortcut, not as definitive model generation. After you run it, you'll want to look over the generated models yourself to make customizations. In particular, you'll need to do this: |
