Django url pattern & ldquo; Does not match & ldquo;

advertisements

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?


Looks like you forgot the url() function:

Try this instead:

from django.conf.urls import url

urlpatterns = patterns('',
    url(r'^news/', include('news.urls')),
)

and news/urls.py:

from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
from django.conf.urls import url

urlpatterns = patterns('news.views',
    url(r'^$', 'news'),
)