我想包括一個Django子應用程序的網址到主要的urls.py中。Django URLConf包括從子應用程序不工作
應用程序/ urls.py:
urlpatterns = patterns(
'',
...
include('transfers.urls'),
)
應用程序/傳輸/ urls.py:
urlpatterns = patterns(
'',
url(r'^transfers/$', 'some.view'),
...
)
,但我得到未找到錯誤的路線。路由的最後一個元素就是子應用程序中的URLconf模塊。它尚未被刪除到父URL列表中。
Using the URLconf defined in app.urls, Django tried these URL patterns, in this order:
1.
2.
...
30. <module 'transfers.urls' from '/path/to/app/transfers/urls.pyc'>
The current URL, transfers/, didn't match any of these.
當我從transfers.urls中將第一個URL模式複製到主要的urls.py中時,它起作用。我似乎包括子應用程序urls.py,但我不確定是否以正確的方式。
我怎樣才能讓它正常工作?
我會建議你仔細閱讀這個,否則你可能會失去很多時間調試只是增加一個額外的$符號或破折號。 https://docs.djangoproject.com/en/1.8/topics/http/urls/ – HassenPy