How to serve a Svelte app frontend build in Django backend static?

The svelte app is normal svelte (not kit) with some routing. Build by npm run build into: /dist: /assets/index.js, /assets/index.css, index.html.

I tried to follow this tutorial for React and expect it to have the same results. When accessed the serving path, it returns

error

In the project app folder:

views.py

from django.shortcuts import render
def index(request):
    return render(request, 'frontend/index.html')

urls.py

urlpatterns = [
    path("admin/", admin.site.urls),
    path("", include("api.urls")),
    path('index/', views.index, name='index'),
]

settings.py

STATIC_URL = "/static/" 
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static/frontend/assets')]
Back to Top