Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

437
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda