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

156
Visualizações
Django & React: Connecting multiple apps from one template

Good morning,

I would like to ask, if it's possible to connect multiple apps in django, each using his own react frontend? For example: I have one main page that holds all the links to the different applications...

Folder-Structure:

|- project
|    |- app_main
|    |    |- templates
|    |    |   |- app_main
|    |    |   |   |- main.html
|    |- app_1
|    |    |- frontend_1 (react)
|    |    |   |- public
|    |    |   |    |- index.html
|    |- app_2
|    |    |- frontend_2 (react)
|    |    |   |- public
|    |    |   |   |- index.html

As I understood - or at least I think so -, the folder holding the html-files have to be included inside the template in settings.py...

settings.py

REACT_ROUTE_APP_1 = os.path.join(BASE_DIR, 'app_1', 'frontend_1', 'public')
REACT_ROUTE_APP_2 = os.path.join(BASE_DIR, 'app_2', 'frontend_2', 'public')

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            REACT_ROUTE_APP_1,
            REACT_ROUTE_APP_2
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

Is this the right way or is there a much better solution? And if it's the right choice, how can I connect the url-route inside my ?

main.html

<div>
    <a href="?">Link to App 1</a>
    <a href="?">Link to App 2</a>
</div>

Even though I thought Django & Reactwould be a popular combination, I found only a few related articles!

Thanks for your help and advice and have a great week!

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

0

Your folder structure is fine , you should use the URL router to redirect from main app to other apps

main urls.py

urlpatterns = [
    path("", include('main.urls')), 
    path("app_1/", include('app_1.urls')), 
    path("app_2", include('app_2.urls')), 

]

And in your app_1 urls.py :

urlpatterns = [
   path('',(TemplateView.as_view(
      template_name="app_1/index.html",
  )), name='index.html'),
]

html


<div>
    #URI + "app_1"
    <a href="app_1">Link to App 1</a>
</div>

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