Forgot Password

Is it possible to use Django when you don't want to create a database through a model?

There are 2 options you have to work with Django when you already have the database tables.

  • You may simply ignore Django ORM since you’re not going to use any its feature and directly communicate with the database with any client library and execute either raw queries or even use SQLAlchemy or any any other method you may see suits you.
  • Use Django InspectDB feature and setup models automatically with the database you want to work with. For this case, simply head over to Integrating Django with a legacy database that explains how to use it. It’s very simple and I’ve done it for many many projects before. Django comes with a utility called inspectdb that can create models by introspecting an existing database.

Depending on how I want to work with, I mostly go with option 2, which is inspectdb feature.

Enjoy hacking <3

Alireza Savand • 2018 Jan 30


@zappycode Yes, I always go with the option 2 since it's much better and easier to work with.

I'll just do:

python inspectdb TABLE_NAME

It will print out the model for me pretty nicely.

Did you end up going with 2?