Legacy database integration
There is an entire section on legacy databases in Django documentation and rightly so, as you will run into them many times. Data is more important than code, and databases are the repositories of data in most enterprises.
You can modernize a legacy application written in other languages or frameworks by importing their database structure into Django. As an immediate advantage, you can use the Django admin interface to view and change your legacy data.
Django makes this easy with the inspectdb
management command, which looks as follows:
$ python manage.py inspectdb > models.py
This command, if run while your settings are configured to use the legacy database, can automatically generate the Python code that will go into your models file. By default, these models are unmanaged, that is, managed = False
. In this state, Django will not control the model's creation, modification, or deletion.
Here are some best practices if you are using this approach to integrate in...