It’s been 10 days of learning Django. I am building a project and have integrated quite number of templates now. However, since yesterday, I encountered an error due to non-addition of slash post the URL. The URL doesn’t reroute for e.g. http://127.0.0.1:8000/login doesn’t open and throws an error where as http://127.0.0.1:8000/login/ opens without an error. I have come across several solutions but they don’t work.
At the start of the project, it worked. But as soon as the complexity of my project grew, the above error came up.
Below are my URL patterns for project.
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path(‘admin’, admin.site.urls),
path(‘’, include(‘application.urls’)),
]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
URL Patterns for my application
from django.contrib import admin
from django.urls import path, include
from . import views
urlpatterns = [
path(‘’, views.home, name=‘home’),
path(‘login/’, views.login, name=‘login’),
path(‘register/’, views.register, name=‘register’),
path(‘logout/’, views.logout, name=‘logout’),
path(‘doctor/’, views.doctor, name=‘doctor’),
path(‘patient/’, views.patient, name=‘patient’),
]