I have developed a website using react as frontend and Django as backend, I have completed the project and made npm run build and I have added the index.html into the Django templates DIR and static files which are inside the build folder
But manifest.json, favicon.ico which is inside the public and build folder are not visible in Django page which localhost:8000, favicon is visible in React page which is in localhost:3000
Project Structure:
Project
|__backend
|__settings.py
|__urls.py
|__base --app
|__views.py
|__models.py
|__build -- reactjs npm run build
|__assets - folder which has images
|__static -- css and scss folder
|__manifest.json
|__favicon.ico
|__index.html
|__public
|__src
|__static -- django static folder
settings.py
STATIC_URL = '/static/'
MEDIA_URL = '/images/'
STATICFILES_DIRS = [
BASE_DIR / 'static',
BASE_DIR / 'build/static',
os.path.join(BASE_DIR, 'build/assets'),
]
MEDIA_ROOT = 'static/images'
urls.py
urlpatterns = [
path('admin/', admin.site.urls),
path('', TemplateView.as_view(template_name='index.html'))
]
urlpatterns += static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)
Errors in terminal:
Not Found: /manifest.json
[04/Sep/2021 14:03:50] "GET /manifest.json HTTP/1.1" 404 2788