In my views.py
I have the following code:
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello, world!")
def show_day(request):
return HttpResponse("The day is: test123")
and in my urls.py
in the application folder, I have:
urlpatterns = patterns('',
url(r'^$', views.index, name='index'),
url(r'^/show_day/$', views.show_day, name='show_day'),
)
now, http://127.0.0.1:8000/myApp
does return the index()
view, but
http://127.0.0.1:8000/myApp/show_day
doesn't, but rather gives a 404 error.
What am I doing wrong? Is the problem with the regex in the URLconf?
You have an unnecessary leading slash in the second URL. It should be
url(r'^show_day/$', views.show_day, name='show_day'),