Home > Blockchain >  Can I deploy a Django App if there is no "" (empty) url?
Can I deploy a Django App if there is no "" (empty) url?

Time:10-14

I'm trying to deploy a Django App with railways for the first time and I was wondering where exactly will be my landing page. So basically my urls.py looks something like this:

path('home/', views.home, name="home"),
path('blogposts/', views.blogposts, name="blogposts"),
path('posts/', views.posts, name="posts"),

After deploying my Blog website, let's say with the domain 12345xxx.com, where will I land?

CodePudding user response:

You will get an error if you don't include a folder in the URL, as the URL patten won't be matched and the existance of non-admin URLs stops the default django page from showing. This will be either a 404 error or a 'Django tried these URL patterns, in this order:' type error if you have DEBUG=True on in settings.

Note that you don't have to provide a path (the path can be an empty string), and views can have multiple paths. In this case, perhaps

path('', views.home, name="home"),
path('home/', views.home, name="home_folder"),
path('blogposts/', views.blogposts, name="blogposts"),
path('posts/', views.posts, name="posts"),

would avoid an error.

  • Related