URLs corrupted on deployment

Hi all,

I am new to Django. I am completing an online course and trying to deploy an app using PlanetHoster. The project (my_site) consists of a single app (blog) (in addition to admin). Everything works perfectly using localhost:8000. In PlanetHoster I created the application my_site and the corresponding url is my_domain/my_site.

It works except that my hyperlinks (and in fact the urls to my static files too) are incorrect:
instead of having a url such as my_domain/my_site/posts/, I get my_domain/my_sit/posts/ (the trailing e in my_site gets dropped)!

Here is urls.py at the project level (my_site):

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('blog.urls')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \
  + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

Here is urls.py at the app level (blog):

urlpatterns = [
    path("", views.StartingPageView.as_view(), name='starting-page'),
    path("posts/", views.AllPostsView.as_view(), name='posts-page'),
    path("posts/<slug:slug>/", views.SinglePostView.as_view(), name='post-detail-page'),
    path("read-later/", views.ReadLaterView.as_view(), name="read-later"),
]

I can get it to work if I replace path('', include('blog.urls')) in the project urls.py with path('blog/', include('blog.urls')). (Of course, in that case, all the blog urls then become my_domain/my_site/blog/....)

I have been trying to figure out what I am not doing right for several days. To no avail! Could you point out what I am missing?

<opinion> My initial reaction is that if this is working fine locally and only failing when deployed that the issue is somewhere in the deployment process. </opinion>

Unfortunately, I’ve never even heard of PlanetHoster before your post here, so I don’t have any idea of even where to look in their docs. (And there aren’t any other references to them in the forum here.)

I would start with looking at whatever documentation they may have on deploying Django in their environment.

Thanks for your comments. PlanetHoster is based in Canada and France. And I did look into their documentation and even opened a ticket - obviously without success so far!

Is there anyway in Django I could print out the intermediate steps from Django from the initial <a href="{% url 'posts-page' %}">All Posts</a> to the generated <a href="/my_sit/posts/">All Posts</a>?

That depends upon whether you have “control” over the installed packages - including Django.

There’s no simple way to print a trace of everything being executed.

You could add a lot of logging throughout the various functions being called - but my starting point would be to see exactly what’s being passed through to Django from the site, which would mean showing all the headers being supplied in the request object. You could probably use Django Debug toolbar for that - that’s probably the easiest way to begin. That will at least help you identify whether the problem is happening before or after the request object has been supplied to you.

I ended up deploying the test app using Railway and it works right off the bat. Therefore, the issue seems to be with the host provider! Thanx again for your help.