[問題] 關於django tutorial
小弟是個django新手,
是的, 現在才進行到 Writing your first Django app, part 2
http://docs.djangoproject.com/en/1.3/intro/tutorial02/
關於Tutorial 1 的每個步驟都完成了, 也無錯誤訊息或結果與預期不同..
但不知為何 part2 的 admin 網頁一直有問題..
多次嘗試後, 發現只要將 urls.py 的
#url(r'^admin/', include(admin.site.urls)),
這行 uncomment 後, 即便是連首頁也有會錯誤
==== 錯誤訊息如下 ====
Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in
this order:
^admin/
The current URL, , 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.
======================
小弟使用的是 Windows 7, Python 2.7, Django 1.3
Try & Google 了一晚, 還是找不出原因... 卡關了.
希望板上的高手可以指點迷津...
謝謝!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.43.215.183
→
04/02 11:12, , 1F
04/02 11:12, 1F
試到最後, 我把tutorial上的整個貼過去了, 還是不行.. :XD
====
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Example:
# (r'^mysite/', include('mysite.foo.urls')),
# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
)
====
早上又試了一些, 還是不 work... 所以我決定先跳過 Part 2
但我發現 Part 3 一些新增的網頁都可以正常的回應...
就唯獨 http://127.0.0.1/admin 這一個頁面還是
====
DoesNotExist at /admin/
Site matching query does not exist.
Request Method: GET
Request URL: http://localhost:8000/admin/
Django Version: 1.3
Exception Type: DoesNotExist
Exception Value:
Site matching query does not exist.
Exception Location: D:\Python27\lib\site-packages\django\db\models\query.py
in get, line 349
Python Executable: D:\Python27\python.exe
Python Version: 2.7.0
Python Path:
['E:\\Work\\Python\\website\\mysite',
'C:\\Windows\\system32\\python27.zip',
'D:\\Python27\\DLLs',
'D:\\Python27\\lib',
'D:\\Python27\\lib\\plat-win',
'D:\\Python27\\lib\\lib-tk',
'D:\\Python27',
'D:\\Python27\\lib\\site-packages',
'D:\\Python27\\lib\\site-packages\\win32',
'D:\\Python27\\lib\\site-packages\\win32\\lib',
'D:\\Python27\\lib\\site-packages\\Pythonwin',
'D:\\Python27\\lib\\site-packages\\wx-2.8-msw-unicode']
Server time: Sat, 2 Apr 2011 12:00:01 +0800
====
請問我是不是某個環境變數, 或是路徑設定上有問題呢?
我看 part 2 裡說的, 理論上 admin 會自己找到對應的 default 位置的 html?
謝謝!
※ 編輯: skiff 來自: 114.43.187.1 (04/02 12:01)
→
04/02 12:47, , 2F
04/02 12:47, 2F
→
04/02 12:48, , 3F
04/02 12:48, 3F
→
04/04 17:23, , 4F
04/04 17:23, 4F
→
04/04 18:22, , 5F
04/04 18:22, 5F
推
04/04 18:26, , 6F
04/04 18:26, 6F
→
04/06 19:51, , 7F
04/06 19:51, 7F
→
04/06 19:52, , 8F
04/06 19:52, 8F
Python 近期熱門文章
PTT數位生活區 即時熱門文章