Reputation: 1
I am learning Django - a few days old. This is my problem.
http://mylocalhost.com:8000/home/ (stack overflow does not allow localhost so used a dummy full domain - mylocalhost.com instead) works when I have this setting in urls.py
url(r'^home/','signups.views.home')
but does not work when I have this setting in urls.py
url(r'^$','signups.views.home',name='home')
I get the following error. #In the error below read mylocalhost.com as localhost. stackoverflow does not allow use of localhost.
Page not found (404) Request Method: GET Request URL: http://mylocalhost.com:8000/home/
^$ [name='home'] The current URL, home/, didn't match any of these.
signups
admin.py
__init__.py
models.py
tests.py
views.py
enter code here
from django.shortcuts import render, render_to_response, RequestContext
def home(request):
return render_to_response("signup.html", locals(),
context_instance=RequestContext(request))
Upvotes: 0
Views: 84
Reputation: 2166
Of course it doesn't work. r'^$'
matches the empty string. You are accesing with the relative path /home
Either make it also the regex url to be r'^home/$'
or simply access localhost:8000/
without the trailing /home
Upvotes: 1