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

277
Visualizações
Import packages from outside django project

Context: The package being considered is an application that was developed by another team and I want to use the functionality exposed as part of an API call in my django project.

Directory layout:

<repo>
├── org_wide_django_code
│   ├── my_django_project
│   │   ├── my_django_project
│   │   ├── manage.py
│   │   ├── requirements.txt
│   │   └── my_application
├── frontend
│   └── application
├── other_team_work
│   ├── README.md
│   ├── __init__.py
│   ├── implemented_logic

What is the best way for me to use other_team_work in my django project my_django_project?

Prior reading:

  • Manipulating PYTHONPATH or sys.path is an option
  • Setting up a .whl or .egg to install other_team_work (also need to add a setup.py there)
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

I am not sure there is a best way since this depends a lot on the internal tooling of your organisation. However the main thing to pay attention to IMO are release and development cycles. Ideally you want both teams to be able to release new features, functionalities without impacting the other. (for instance if other_team makes a change to their code for a third team you would like this to have no possible impact on your application. Similarly other_team should not need to know how and when you use their module to make changes to their application.

One way to do this would be to have other_team_work be packaged and installable (using a setup.py) and then pushed to a package registery (for instance gitlab's package registery or github packages). This way you can use other_team_work as though it were just another python package with pip (using the extra-package-url argument) and using specific versions in a requirements.txt.

over 4 years ago · Santiago Trujillo Relatório

0

The simplest way (but can be dangerous) is add other_team_work to your project in PYTHONPATH. You can add this to django settings.py file, after BASE_DIR definition. Example:

import sys

BASE_DIR = Path(__file__).resolve().parent.parent  # default Django base dir
OTHER_TEAM_WORK_PARENT_DIR = BASE_DIR.parent  # in accordance with your directories
sys.path.append(str(OTHER_TEAM_WORK_PARENT_DIR))

This code add your directory org_wide_django_code to PYTHONPATH and you can import other_team_work in your code:

from other_team_work import implemented_logic
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