Forgot Password

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

Yes, you can for sure do that.

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 which 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 inspechttps://docs.djangoproject.com/en/dev/ref/django-admin/#django-admin-inspectdbtdb 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 Mar 03

Be the first to comment.