Django URLS, how to map root to app?

后端 未结 7 1004
迷失自我
迷失自我 2021-01-30 08:43

I am pretty new to django but experienced in Python and java web programming with different frameworks. I have made myself a nice little django app, but I cant seem to make it m

7条回答
  •  臣服心动
    2021-01-30 08:58

    I know that this question was asked 2 years ago, but I've faced the same problem and found a solution:

    In the project urls.py:

    urlpatterns = patterns('',
        url(r'^', include('my_app.urls')), #NOTE: without $
    )
    

    In my_app.urls.py:

    urlpatterns = patterns('',
        url(r'^$', 'my_app.views.home', name='home'),
        url(r'^v1/$', 'my_app.views.v1', name='name_1'),
        url(r'^v2/$', 'my_app.views.v2', name='name_2'),
        url(r'^v3/$', 'my_app.views.v3', name='name_3'),
    )
    

提交回复
热议问题