When I syncdb and runserver everything works correctly in Django, but when I try to visit the webpage that it is on http://127.0.0.1:8000/
it returns a 404 error.
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/
Using the URLconf defined in MyBlog.urls, Django tried these URL patterns, in this order:
^admin/
The current URL, , didn't match any of these.
The strange part is that when I visit /admin
on the page it works fine. I dont understand what is failing here. Any help would be awesome!
You need an URL route to the homepage. The urlpatterns variable in MyBlog.urls should have a tuple pair like (r'^$', app.views.show_homepage), where show_homepage is a function defined in views.py. For more info about the URL dispatcher, you can read about it here: https://docs.djangoproject.com/en/dev/topics/http/urls/
Check out chapter 3 of Django's Writing your first Django app tutorial.
In short, you need to specify (in
urls.py
) which code Django should run for particular URLs; there are no default URLs defined (you'll see a line including the admin URLs inurls.py
).Edit your
urls.py
so it looks something like(you'll also need to create
home.html
in one of the directories specified inTEMPLATE_DIRS
)