Create models table from exists database?

40 views
Skip to first unread message

Dario Concilio

unread,
Apr 21, 2015, 5:00:16 AM4/21/15
to django...@googlegroups.com
Hi to all!
I'm new of django, I've a question for you: Can I create a new project using an exists database?

I've a domotic system on Ubuntu Server, with a Postgres database that has several table. Actually the system uses a table by a python service and PHP portal for data management of domotic configuration.

I would change portal admin with a "django" portal, can I create a new django project using this database?
Django framework allows me to generate the system tables and complete models (model.py) from existing ones?

PS: I imagine this approach as the technique called "Database First" of various ORM.

Thanks to all.

David Palao

unread,
Apr 21, 2015, 5:34:18 AM4/21/15
to django...@googlegroups.com
Hi,
Yes, in principle you can.The keywords are "legacy database":
https://docs.djangoproject.com/en/1.8/howto/legacy-databases/

Best
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e38f24fd-ebce-40ff-b53b-b94c5234d07a%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

felix

unread,
Apr 21, 2015, 8:23:36 AM4/21/15
to django...@googlegroups.com
El 21/04/15 03:15, Dario Concilio escribió:
Hi to all!
I'm new of django, I've a question for you: Can I create a new project using an exists database?

I've a domotic system on Ubuntu Server, with a Postgres database that has several table. Actually the system uses a table by a python service and PHP portal for data management of domotic configuration.

I would change portal admin with a "django" portal, can I create a new django project using this database?
Django framework allows me to generate the system tables and complete models (model.py) from existing ones?


Check Legacy databases in the official doc. This is what you're looking for:

python manage.py inspectdb

Cheers.

Dario Concilio

unread,
Apr 21, 2015, 9:06:37 AM4/21/15
to django...@googlegroups.com
Great!
Thank you!
Reply all
Reply to author
Forward
0 new messages