Wednesday 10:30 a.m.–11 a.m.

From Legacy to Admin

Chris Cabral

Audience level:



For those who have not had the pleasure of seeing django's inspectdb command in action, I will create a demonstration of it's power. Django's inspectdb command can reverse engineer a set of models from a postgres or mysql database. I will demonstrate how to take a legacy database and create a quick and dirty admin tool along with a simple rest interface.


When working with a legacy system, the inspectdb command can save days of hard work. However, even though inspectdb is magic, it not a cure all. Inspectdb treats mysql and postgres differently. I will go over the output produced per database as well as how to integrate those outputs into a working django admin and rest interface.

We will dive into the source code to see how the output is generated, where it falls short, as well as where it excels. We will examine which foreign key relationships, unique constraints, field names, table names, primary key fields, and auto-populated fields that can cause issues with introspection. After we have a working application with a reverse engineered model, we will setup validations for some of our minor business logic so we can have a fully functioning django admin.

I will also create a data fixture set from the legacy database in order to be able to share the entire application with another developer as fast as possible. Finally, I will also go into short detail in ways to quickly make a bootstrapped django admin interface and a simple rest interface using third party apps like django-rest-framework. The goal of the presentation is to realize how much of the work you can let django do for us as to minimize the work we have to do.