Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

247
Visualizações
Register SQL-table in Django admin

If I have a PostgresDB that contains both Django models and other SQL tables, is it possible to register these other SQL tables in the Django admin panel?

More details about the setup: I have a docker-compose setup where Django is running in one container, a Postgres DB in another, and a slack-app in a third container. Django is connected to the DB and the models are registered in the admin panel. This works as intended. The slack-app is also connected to the same DB and has some tables there that are not Django-models. I would like to also access these through the Django admin panel in order to have everything in one place. Is this possible?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You can define unmanaged models in Django. These models will not construct migrations, but will only query the database to select, insert, etc.

Django offers a tool inspectdb [Django-doc] to inspect the database and write the corresponding unamanged models. You thus can use this with:

python3 manage.py inspectdb table1 table2 tablen

It will then write the corresponding models for these tables to the standard output channel, and you thus can copy these in the models.py. In the Meta of these models it will add a managed = False to denote that Django will not migrate these models.

Once you registered these models, you can register a ModelAdmin with:

from django.contrib import admin
from app_name.models import Model1, Model2, Modeln

admin.site.register(Model1)
admin.site.register(Model2)
admin.site.register(Modeln)
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda