DEV Community

Discussion on: Django + Svelte = Best Dev Experience (DX)

Collapse
nathanael71 profile image
Nathanael

Hi Ashraf,
Thank you for this article. It is very informative and enjoyable to follow.
If I may, I want to ask about the routing part.

On project-level url pattern list, you add:

path('example/', include('example.urls'))

I want to serve the svelte-part on root url so I tried to adapt with:

path('', include('example.urls'))

My all urlpatterns are:

    path('admin/', admin.site.urls),
    path('', include('example.urls')),
Enter fullscreen mode Exit fullscreen mode

but when I build-run-open in browser: localhost:8000/admin,
The app seems to ignore my 'admin/' urlpattern and got handled by routify instead (which then show 404 error page because there's no 'admin/' routes configured on routify).

My question is: is it possible to let django serve svelte-routify on root url without ignoring other urlpattern rules on django's urls.py?

Thanks in advance

Collapse
ashraf_zolkopli profile image
ashrafZolkopli Author

I asked the Routify Discord first if they have any idea on how to do it. If any update I will reply to this comment and/or update the tutorial

Collapse
ashraf_zolkopli profile image
ashrafZolkopli Author

First of all sorry, for the late reply. I haven't been checking up with Dev.to in a while.

Honestly, I don't know. I haven't try it that way yet.
I will try to investigate if its possible to force the browser to stop SPA mode and make a request to the Django Server

Collapse
ashraf_zolkopli profile image
ashrafZolkopli Author

Hi,

I received an answer from the Discord already.

Alt Text

with this, I made some changes to the configurations, and found that it is indeed possible to have Django server the request to admin page.

Alt Text

currently my url are as above.

then what I did was change the url to become

Alt Text

what I found was that the root was serve by Routify

Alt Text

while admin is being serve by django

Alt Text

I hope this helps...