Django how to set the default application for the home URL?


I'm learning Django, and so far I always had to use URL's like


but what if I don't want appname to appear in the URLs for the "default" app, how can I configure my urls so that


will load the view viewname from my default app?

P.S. : Of course my primary goal is to be able to use the URL projectname/ to load the default view for the default app.


Currently my ProjectName/ has this:

urlpatterns = patterns('',
url(r'^static/(?P<path>.*)$', 'django.views.static.serve',
    {'document_root', settings.STATIC_ROOT}
    url(r'^admin/', include(,
    url(r'^myapp1/', include('myapp1.urls', namespace='myapp1', app_name='myapp1')),
    url(r'^myapp2/', include('myapp2.urls', namespace='myapp2', app_name='myapp2')),

so when I deploy my project to Heroku, and visit, I get the error :

Page not found (404)
Request Method: GET
Request URL:
Using the URLconf defined in MyProject.urls, Django tried these URL patterns, in this order:

I know this is supposed to be, but how do I fix (or hack) this to get to work?

If not possible, how can I redirect the homepage to myproject/myapp1/defaultview ? Thanks in advance !

my app's looks like this :

urlpatterns = patterns('myapp1.views',
    url(r'^view1/$', 'view1', name='view1'), # the default view
    url(r'^view2/(?P<oid>\d+)/(?P<pid>\d+)/$', 'view2', name='view2'),


After trying @Wallace 's suggestion url(r'^$', include('myapp1.urls', namespace='myapp1', app_name='myapp1')), and hitting the homepage, I now get the error:

Using the URLconf defined in myproject.urls, Django tried these URL patterns, in this order:
^$ ^view1/$ [name='view1']
^$ ^view2/(?P<oid>\d+)/(?P<pid>\d+)/$ [name='view2']

Tried changing your project with:

url(r'', include('myapp1.urls', ...)

This will include all urls from myapp1.urls where they all append to /.

The reason why r'^$' won't work is because the regex ends with $ which means there can only be 1 x url /, and because your app1.urls only has 2 urls defined and without a / or ^$ equivalent, the url resolver will then fail.

But be aware of url clashes, if your project has a ^view1/$ url it will clash to your app1's view1 for example.