codyc4321
codyc4321

Reputation: 9682

Page not found (404) in Django view

I am trying to wire up a view based on the Django tutorial (1.8), and am for some reason not getting a basic url to work:

Page not found (404)

Settings

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'events',
)

In the main folder, I have these_events/these_events/urls.py

from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
    url(r'^admin/', include(admin.site.urls)),
    url(r'^/', include('events.urls')),
]

In the events app, I have these_events/events/urls.py

from django.conf.urls import url

from . import views

urlpatterns = [
    url(r"^$", views.search_db, name='search-db')
]

these_events/events/views.py:

from django.shortcuts import render
from django.http import HttpResponse

def search_db(request):
    return HttpResponse("hello, world")

This has me befuddled as I followed the example, and this is the way I remember using Django in the past.

Upvotes: 0

Views: 55

Answers (1)

NS0
NS0

Reputation: 6106

In these_events/these_events/urls.py

try changing

url(r'^/', include('events.urls')),

to

url(r'', include('events.urls')),

Upvotes: 2

Related Questions