0

ROOT_URLCONF私のプロジェクトのsettings.pyで(登録と呼ばれる)さまざまな文字列に設定しようとしました: ROOT_URLCONF = 'registration.urls'、、、、。ROOT_URLCONF = 'foo.urls'ROOT_URLCONF = 'monkey.urls'ROOT_URLCONF = 'registration.registration.urls'

とにかく、ホームページに次の出力が表示されます。

Page not found (404)
Request Method: GET
Request URL:    http://78.198.124.245/
Directory indexes are not allowed here.
You're seeing this error because you have DEBUG = True in your Django settings file.

何故ですか?Passenger の設定に使用しているファイル (passenger_wsgi.py) を次に示します。このファイルは「/home/david/registration/registration/」にあります。

import os, sys

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "registration.settings")

# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

sys.path.append(os.getcwd())
sys.path.append("/home/david/registration/registration")
sys.path.append("/home/david/registration/registration/app")

/home/david/registration/registration/urls.py はこんな感じ。

from django.conf.urls import patterns, include, url, http

def myFunction(request):
    return http.HttpResponse("A mapped URL")

urlpatterns = patterns('',
    (r'^$', 'myFunction')
)

Django アプリケーションが ROOT_URLCONF 設定を完全に無視し、ホームページにアクセスするたびに同じ出力を返すのはなぜですか?

4

1 に答える 1

0

あなたの試みは実際にはpythonパスに存在しません。パスが/home/david/registration/registrationあり、URL が含まれている場合/home/david/registration/registration/urls.py、1 番目から 2 番目への相対パスは何になりますか?

于 2012-05-18T05:07:46.353 に答える