CRUD Operations Without Model

63 views
Skip to first unread message

LiquidOxygen SpiritsGenuine

unread,
Mar 26, 2020, 8:48:23 AM3/26/20
to Django users
Hello All..

I am using PostgreSQL as my database. I already have the tables created.
I just want to use DJango/Python APIs to perform CRUD operations without re-creating the tables again using Model. 

Please help.

pot-potato

unread,
Mar 26, 2020, 10:10:23 AM3/26/20
to Django users
Hey, whatever your name is,

There is a command called inspectdb in Django (python manage.py inspectdb). Basically it reads database tables configuration and creates a models script.

which can be copied into models.py then use it. And make sure that they are in models class meta for these tables are set to managed = False.

if managed set to false then Django will not modify database tables. But there is a catch, You have to manually update model if you change any table configuration from database side like form pgadmin4.


Thanks and Regards,
Naveen
Reply all
Reply to author
Forward
0 new messages