views:

308

answers:

1

I've been messing around with Django and the Django ORM at home, and I've got to say, I feel it is one of the best out there in terms of ease of use.

However, I was wondering if it was possible to use it in "reverse".

Basically what I would like to do is generate Django models from an existing database schema (from a project that doesn't use django and is pretty old).

Is this possible?

Update: the database in question is Oracle

+9  A: 

Yes, take a look at the insepectdb command:

inspectdb

Introspects the database tables in the database pointed-to by the DATABASE_NAME setting and outputs a Django model module (a models.py file) to standard output.

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:

[...]

ars
perfect, thanks!
TM
Reading over that info, it says it is supported for mysql, sqlite, and postgresql. Sadly the database I am trying to use is Oracle :(
TM
oof, I don't believe Django has good support for Oracle at the moment, both forwards or backwards : /
AlbertoPL
It works also for Oracle - I've used it in that way.
Roberto Liffredo