B
B
BoryanNikitin2019-10-17 15:37:30
PostgreSQL
BoryanNikitin, 2019-10-17 15:37:30

Is it possible to import a DB schema into a Django model?

There is a PostgreSQL schema code in the following form:

CREATE TABLE "messages" ( 
  "id" uuid NOT NULL, 
  "text" TEXT NOT NULL, 
  "category_id" uuid NOT NULL, 
  "posted_at" TIME NOT NULL, 
  "author_id" uuid NOT NULL, 
  CONSTRAINT "messages_pk" PRIMARY KEY ("id") 
  ) WITH (  
  OIDS=FALSE 
);

...
...

Is there any way to import this database schema into a Django project?
It is clear that it is possible to write models that fit this pattern and migrate, but my question is, how do I do it back? To receive models in the project on the DB designed from the outside?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2019-10-17
@BoryanNikitin

Everything is described in the Django documentation:
https://docs.djangoproject.com/en/2.2/howto/legacy...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question