Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

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

$
0
0

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

TemplateDoesNotExist at /index/frontend/index.htmlRequest Method: GETRequest URL:    http://127.0.0.1:8000/index/Django Version: 5.0.1Exception Type: TemplateDoesNotExistException Value:    frontend/index.html

In the project app folder:

# views.pyfrom django.shortcuts import renderdef index(request):    return render(request, 'frontend/index.html')# urls.pyurlpatterns = [    path("admin/", admin.site.urls),    path("", include("api.urls")),    path('index/', views.index, name='index'),]# settings.pySTATIC_URL = "/static/" STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static/frontend/assets')]

Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>