What is the best way to map the main django project urls?

I have a django project that contains some applications. The main urls.py includes urls.py from the applications that I have included, and all this is good.

Now I want to configure the project so that when you go to http: // testsite / you get the same page as you do when you go to http: // testsite / app / .

I can do this by duplicating the corresponding line in urls.py applications in urls.py projects, but it seems dirty.

Does anyone know a better way?

+3
source share
2 answers

Configure redirect_to from the first URL to the second, i.e.:

from django.conf.urls.defaults import patterns, url, include
from django.views.generic.simple import redirect_to

    urlpatterns = patterns('',
        # Example:
        url(r'^$', redirect_to, {'url':'/app/'}),
        url(r'^app/', include('app.urls')),
        # ...
    )

NTN

+6

- , URL- ( Google). , . , Django redirect_to urlconf, Apache nginx insert-your-webserver, Django .

+1

All Articles