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并且网址在其中,/home/david/registration/registration/urls.py那么从第一个到第二个的相对路径应该是什么?

于 2012-05-18T05:07:46.353 回答