Re: [問題] Django新手 runserver失敗

看板Python作者 (錯字王)時間7年前 (2017/06/18 19:56), 編輯推噓2(2015)
留言17則, 5人參與, 最新討論串2/2 (看更多)
這是我的資料夾結構 mysite/ manage.py db.sqlite3 mysite/ __init__.py settings.py urls.py wsgi.py __pycache__/ __init__.cpython-34.pyc settings.cpython-34.pyc urls.cpython-34.pyc wsgi.cpython-34.pyc polls/ __init__.py admin.py apps.py migrations/ __init__.py models.py tests.py views.py 我把polls 移往下一層(mysite內)執行後 ----cmd 顯示---- (myvenv) C:\Users\peng\Django>python .\mysite\manage.py runserver Performing system checks... System check identified no issues (0 silenced). June 18, 2017 - 19:38:53 Django version 1.11.2, using settings 'mysite.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK. -----瀏覽器顯示---- Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/ Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order: ^polls/ ^admin/ The empty path didn't match any of these. You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page. -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.167.50.89 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1497786964.A.94A.html

06/18 20:16, , 1F
url 沒匹配到呀 去 127.0.0.1:8000/polls 看看
06/18 20:16, 1F

06/18 20:16, , 2F
錯誤訊息蠻清楚的
06/18 20:16, 2F

06/18 20:19, , 3F
教學明明是寫Go to http://localhost:8000/polls/
06/18 20:19, 3F

06/18 20:20, , 4F
別照抄都抄錯了
06/18 20:20, 4F

06/18 20:21, , 5F
可以學一下regular expression
06/18 20:21, 5F

06/18 20:32, , 6F
謝謝djshen,不過還是不知道為什麼要移到下一層才能動
06/18 20:32, 6F

06/18 20:43, , 7F
如果直接startapp polls 還要移動到下一層才能用
06/18 20:43, 7F

06/18 20:44, , 8F
有點奇怪,不知道是哪邊出了問題?
06/18 20:44, 8F

06/18 20:45, , 9F
a大 我會去學一下的 謝謝
06/18 20:45, 9F

06/18 21:00, , 10F
因為你執行 startapp 的位置就錯了, 應該要在 manage.py
06/18 21:00, 10F

06/18 21:01, , 11F
那層執行才對, 不是在外面執行
06/18 21:01, 11F

06/18 21:27, , 12F
要怎麼設定呢?因為照著步驟走就出現在那個位置上
06/18 21:27, 12F

06/18 21:33, , 13F
不需要怎麼設定啊, 就 cd 進去 manage.py 那層再下指令
06/18 21:33, 13F

06/18 21:33, , 14F
你之後的所有指令也都應該在那層執行才對啊
06/18 21:33, 14F

06/18 21:40, , 15F
十分感謝,剛剛重做一次很順利的完成
06/18 21:40, 15F

06/18 22:05, , 16F
指令是打manage.py 就要在manage.py那層的路徑才能執
06/18 22:05, 16F

06/18 22:05, , 17F
06/18 22:05, 17F
文章代碼(AID): #1PHcfKbA (Python)
文章代碼(AID): #1PHcfKbA (Python)