Django URLS, how to map root to app?

后端 未结 7 1125
迷失自我
迷失自我 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 09:07

    I know the answer is late, but i had my fair share of hunting recently. This is what i tried with CBV.. in Project urls.py

    urlpatterns = [
        url(r'^admin/', admin.site.urls),
        url(r'^$', include('app_name.urls', namespace='app_name')),
    ]
    

    PS: It is always recommended to use namespace. Gives a good advantage later on.

    In App urls.py

    urlpatterns = [
        url(r'^$', views.IndexPageView.as_view(), name='index'),
    ]
    

提交回复
热议问题