views:

232

answers:

2

Hi everyone,

Our website uses a PHP front-end and a PostgreSQL database. We don't have back-end at the moment except a phpPgAdmin. The database admin has to type data into phpPgAmin manually, which is error-prone and tedious. We want to use Django to build a back-end.

The database has few dozens of tables already there. Is it possible to import the database schema into Django and create Models automatically?

Many thanks

A: 

If each table has an autoincrement integer PK then you can use the legacy database instructions.

Ignacio Vazquez-Abrams
+3  A: 

Yes it is possible, using the inspectdb command:

django-admin.py inspectdb

This will look at the database configured in your settings.py and outputs model classes to standard output.

As Ignacio pointed out, there is a guide for your situation in the documentation.

TM