Two projects use the same Postgres Datebase and the Django project



  • I have two projects that use the same Postgresql Datebase. One of these projects is written from the Golang and the other from Django. I have a Django project task to collect data from the table that is being developed in another project. Or rather, I have to get data from the Clients table that isn't created in Django. Django no information is available on this table.

    Downstairs, I take data from Sok's table, which is being the Django project. введите сюда описание изображения

    How can I get the data from the Clients table in the same way?

    Both project repositories down there, and discounts from the date.

    введите сюда описание изображения

    введите сюда описание изображения

    Thank you.



  • I wrote this question in English, too, with these answers, I've made the task.

    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 something like



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2