Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

the requested URL was not found on this server django

I am following a youtube tutorial, and am getting an error...

getting an error

The requested URL /hello was not found on this server.

site/urls.py

urlpatterns = patterns('',
    url(r'^hello/$', article.views.hello),
    ...
)

article/views.py

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

def hello(request):
  name = 'mike'
  html = '<html><body> sup %s </body></html> ' %name
  return HttpRequest(html)

site/settings.py

INSTALLED_APPS = (
    ...
    'article',
)
like image 517
bezzoon Avatar asked Oct 18 '14 03:10

bezzoon


Video Answer


1 Answers

The request url /hello does not have a trailing slash (/). You can make the url pattern match / optionally by appending ?:

url(r'^hello/?$', article.views.hello),
like image 64
falsetru Avatar answered Sep 21 '22 17:09

falsetru