zan
zan

Reputation: 594

Invalid Django URL does not display error page

I'm having a problem in Django whereby having a paginated URL that does not exist still loads the default page.

The url.py is as follows:

from django.conf.urls import patterns, include, url
from django.contrib import admin
from account.views import ProfileView
from photo.views import IndexView

admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'photofolio.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),
    url(r'^$', IndexView.as_view(), name = 'index'),
    url(r'^admin/', include(admin.site.urls)),,
    #url(r'^$', TestView.as_view(), name = 'main'),
)

When loading a URL such as 127.0.0.1/?page=99, the dafault page is loaded although there are only 2 pages. For any other invalid URL 127.0.0.1/abc, the Not Found error page is displayed. Am I missing some setting?

Upvotes: 0

Views: 123

Answers (1)

Daniel
Daniel

Reputation: 42768

A URL consists of a few parts, the protocol, the host with port, the path, and the parameters. Everything after '?' are parameters; in the Django urlpatterns you only give the path, the parameters are stored in request.GET. In your example, the path is '' and therefore matches the IndexView.

Upvotes: 2

Related Questions