[Answered ]-Page not found (404) in django tututorial

2👍

You don’t have a base url defined. You need something like –

urlpatterns = patterns('',

    # ...
    url(r'^$', HomeView.as_view())

)

You should be able to see your site at – localhost:8000/admin/ (assuming you’re running your dev server with python manage.py runserver).

Django checks all the URL’s you’ve defined in your url conf file and looks for one that matches the url you’ve entered in the browser. If it finds a URL that matches then it serves up the http response returned by the url’s corresponding view (HomeView in the code above). The urls.py file is matching url’s to views. Views return the http response.

Looking at the error message you’ve got (and the code you’ve included from the url.py file), you can see that there’s only one url defined in your app – admin/. Trying to get a page at any other url will fail.

For more information have a look at the docs for django’s URL Dispatcher.

Leave a comment