Reputation: 3194
I have recently created a PHP application which connects to my MySQL database and displays the table information. Where Django is concerned, I am only familiar with them being created in SQLite by creating the relevant models.
Is there a way to do this in reverse? So have Django create models from the tables in MySQL?
Upvotes: 3
Views: 7594
Reputation: 34553
You can use your existing schema to create tables. The official documentation is at: https://docs.djangoproject.com/en/1.7/howto/legacy-databases/
There are two commands:
python manage.py inspectdb
This will give you the output of running:
python manage.py inspectdb > models.py
Django won't know how you want to break these models up into separate application modules, so you'll need to do that on your own, if necessary.
Upvotes: 4