Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

436
Views
Two projects use the same Postgres database, and the project on Django

I have two projects that use the same Postgresql database. One of these projects is written with Golange and the other with Django. I have a task in the Django project, to take the data from the table that is created in another project. More precisely I have to take the data from the Clients table, which is not created in Django. There is no information about Clients table on the Django project.

Below is how I take the date from the Cook table, which is created in the Django project.

enter image description here

How can I take the date from the Clients table in the same way as above?

Below are both project repositories, and some screenshots from the database.

https://github.com/NarminSH/Go-Client.git

https://github.com/NarminSH/Lezzetly

enter image description here

enter image description here

Thanks in advance.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You have a couple of options:

  • Use Django's raw SQL queries to just SELECT data from that table
  • Use inspectdb to have Django generate a model for the clients table. The model will have Meta.managed set to False, so Django won't touch it (e.g. do migrations). You can then use regular Django ORM operations for it.
  • Manually write the model, setting db_table = "clients" and managed = False on the Meta class. You can then use regular Django ORM operations for it.

The model Django (or you) might generate could look something like

class Client(models.Model):
    id = models.IntegerField(primary_key=True)
    first_name = models.CharField(max_length=50)
    last_name = models.CharField(max_length=50)
    # ... etc ...

    class Meta:
       managed = False
       db_table = 'clients'
over 4 years ago · Santiago Trujillo Report

0

Create Django models based on the database structure by introspecting an it with inspectdb command:

$ python manage.py inspectdb > models.py

Then you can query the database with Django API.

Have a look at https://docs.djangoproject.com/en/3.2/howto/legacy-databases/#auto-generate-the-models

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!