I have the following code in my urls.py:
urlpatterns = patterns('',
(r'^news/', include('news.urls')),
)
When I try to open
http://localhost/news
or
http://localhost/news/
in the browser django shows me 404 page:
Using the URLconf defined in python.urls, Django tried these URL patterns, in this order:
^news/
The current URL, , didn't match any of these.
UPD:
news/urls.py:
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
urlpatterns = patterns('news.views',
(r'^$', 'news'),
)
There is views.py in news directory and it contains news function.
And news module is added to INSTALLED_APPS.
Why it cannot find news pattern? Any suggestions?
I think it may be a problem with your views.py this url on the django docs tells you how to dispatch the urls properley
https://docs.djangoproject.com/en/dev/topics/http/urls/
In which port your application launches? When I see your tries
http://locahost/news
it might be that you forgot to use the right port.Try to visit
http://localhost:8000/
andhttp://localhost:8000/news
.Looks like you forgot the
url()
function:Try this instead:
and news/urls.py: