[Answered ]-How to map URLs to views in django?

1πŸ‘

βœ…

So to achieve your goal, change the projec’s url file as:

    path('admin/', admin.site.urls),

    path('task/',include('todolist_app.urls')),

    path('',include('todolist_app.urls')), # change as this

Then you can get the following things:

127.0.0.1:8000/about showing "welcome to about page"

127.0.0.1:8000/contact showing "welcome to contact page"

127.0.0.1:8000/ showing "welcome to todolist app page"

The problem here was in project url file when you add path('todolist/',include('todolist_app.urls')), every urls in the todolist app will be prefixed with the given string in project url file.

You can refer Django – URL Mapping for more.

πŸ‘€ilyasbbu

0πŸ‘

Add a slash after your route:

from django.urls import path

from todolist_app import views

urlpatterns = [

    path('', views.todolist),

    path('contact/', views.contact,name='contact'),

    path('about/', views.about, name='about'), #the path can be anything.

]
πŸ‘€Iqbal Hussain

Leave a comment