Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
Las imágenes en django no aparecen en reaccionar

Esta es una aplicación en la que estoy usando django backend y react frontend. Las imágenes se muestran en reaccionar cuando mantengo a reaccionar y django separados y me comunico simplemente con las API. Sin embargo, quiero implementar tanto el frontend como el backend juntos. Estoy tratando de usar django re_path para redirigir cualquier URL que no coincida con las URL especificadas en django urls.py Cada vez que hago esto, las imágenes de reaccionar y django dejan de mostrarse. Tanto django como react pierden la pista de la ruta de las imágenes.

 project structure >backend ... settings.py urls.py >blog ... urls.py serializers.py views.py >frontend ... build src package.json manage.py >static

urls.py

 urlpatterns = [ path('admin/', admin.site.urls), path('api/', include('djoser.urls')), path('api/', include('djoser.urls.jwt')), path('api/', include('accounts.urls')), path('summernote/',include('django_summernote.urls')), path('api/blog/', include('blog.urls')), re_path('*', TemplateView.as_view(template_name='index.html')), ]

configuración.py

 urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ os.path.join(BASE_DIR, 'frontend/build') ], 'APP_DIRS': True, }, ] STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static',), os.path.join(BASE_DIR, 'frontend/build/static'), ] MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')

¿Cómo puedo solucionar esto? Estoy usando Django v4

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Finalmente lo arreglé usando ruta en lugar de re_path. Tuve que cambiar re_path('*', TemplateView.as_view(template_name='index.html')) a re_path('', TemplateView.as_view(template_name='index.html')) . No se si cambios respecto al uso de repath en Django 4.0

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!