Reputation: 110502
I'm just learning Django and trying to setup the View and URLconfs (http://djangobook.com/en/2.0/chapter03/).
Inside my project folder "mysite" (/Users/NAME/Desktop/development/Python/djcode/mysite), I have the following two files:
views.py
from django.http import HttpResponse
def hello(request):
return HttpResponse("Hello world")
and urls.py
from django.conf.urls.defaults import *
from mysite.views import hello
urlpatterns = patterns('',
(r'^hello/$', hello),
)
However, when I run the test server, it shows a 404 page saying:
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
^hello/$
The current URL, , didn't match any of these.
I think this has to do with my settings.py not being correct. What do I need to change in the settings.py file to point it to the correct destination?
Upvotes: 1
Views: 1515
Reputation: 1728
Looks like the URL you entered when testing it was "http://localhost:8000/". You should enter "http://localhost:8000/hello/" to see the output of the function you made.
Upvotes: 0
Reputation: 799370
You have no urlconf pattern corresponding to the root of your webserver. Add ^$
and make it go somewhere.
Upvotes: 1