Django+;mod#u python+;apache:管理面板和URL不';行不通

Django+;mod#u python+;apache:管理面板和URL不';行不通,python,django,mod-python,Python,Django,Mod Python,这一整天我都在尝试在生产服务器上配置django。我使用mod_python。当我打开http://beta.example.com时,我看到了我的网站,但http://beta.example.com/admin和http://beta.example.com/441/abc/不起作用: Page not found (404) Request Method: GET Request URL: http://beta.example.com/admin {'path': u'a

这一整天我都在尝试在生产服务器上配置django。我使用mod_python。当我打开http://beta.example.com时,我看到了我的网站,但http://beta.example.com/admin和http://beta.example.com/441/abc/不起作用:

Page not found (404)
Request Method:     GET
Request URL:    http://beta.example.com/admin

{'path': u'admin'}

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.


Page not found (404)
Request Method:     GET
Request URL:    http://beta.example.com/441/abc/

{'path': u'441/abc/'}

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.
我的网址:

from settings import MEDIA_ROOT
from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # static files
    url(r'^static/javascripts/(?P<path>.*)$', 'django.views.static.serve',
        {'document_root': MEDIA_ROOT + '/javascripts'}, name='javascripts'),
    url(r'^static/images/(?P<path>.*)$', 'django.views.static.serve',
        {'document_root': MEDIA_ROOT + '/images'}, name='images'),
    url(r'^static/stylesheets/(?P<path>.*)$', 'django.views.static.serve',
        {'document_root': MEDIA_ROOT + '/stylesheets'}, name='stylesheets'),
    url(r'^static/(?P<path>.*)$', 'django.views.static.serve',
        {'document_root': MEDIA_ROOT}, name='static'),
    (r'^admin/', include(admin.site.urls)),
    url(r'^/?$', 'content.views.index', name='root-url'),
    url(r'^(?P<id>[0-9]{2,5})/(?P<slug>[a-z\-]+)/?$', 'content.views.show', name='show-url'),

)
从设置导入媒体\u根目录
从django.conf.url.defaults导入*
从django.contrib导入管理
admin.autodiscover()
urlpatterns=模式(“”,
#静态文件
url(r'^static/javascripts/(?P.*)$,'django.views.static.service',
{'document_root':MEDIA_root+'/javascripts'},name='javascripts'),
url(r“^static/images/(?P.*)$”,“django.views.static.service”,
{'document'u root':MEDIA'u root+/images'},name='images'),
url(r“^static/stylesheets/(?P.*)$”,“django.views.static.service”,
{'document_root':MEDIA_root+/stylesheets'},name='stylesheets'),
url(r'^static/(?P.*)$,'django.views.static.service',
{'document_root':MEDIA_root},name='static'),
(r“^admin/”,包括(admin.site.url)),
url(r'^/?$','content.views.index',name='root-url'),
url(r'^(?P[0-9]{2,5})/(?P[a-z\-]+)/?$”,'content.views.show',name='show-url'),
)
阿帕奇:

DocumentRoot "/var/www/django/beta.example.com/site"

<Location "/">
  allow from all
  SetHandler python-program
  PythonHandler django.core.handlers.modpython
  SetEnv DJANGO_SETTINGS_MODULE site.settings
  PythonOption django.root /
  PythonDebug On
  PythonPath "['/var/www/django/beta.example.com', '/var/www/django/beta.example.com/site'] + sys.path"
</Location>

<Location "/static" >
  SetHandler none
</Location>
DocumentRoot”/var/www/django/beta.example.com/site
通融
SetHandler python程序
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_设置_模块site.SETTINGS
滇蟒/
蟒蛇
PythonPath“['/var/www/django/beta.example.com','/var/www/django/beta.example.com/site']+sys.path”
SetHandler无

我不知道出了什么问题。

我只是想说出来,但你必须在设置文件中启用django管理中间件。它就在那里,但在开箱即用。如果您已经这样做了,我不知道您的问题是什么。

我只是把它扔出去,但是您必须在设置文件中启用django管理中间件。它就在那里,但在开箱即用。如果您已经这样做了,我不知道您的问题是什么。

不确定这是否能解决您的问题,但在我的site.conf for django中,我不得不评论这句话:

PythonOption django.root/


让它工作。

不确定这是否能解决您的问题,但在my site.conf for django中,我不得不评论这句话:

PythonOption django.root/


让它工作。

您真的不想使用mod_python进行部署。我强烈建议转移到mod_wsgi进行Django depoyment

您真的不想使用mod_python进行部署。我强烈建议转移到mod_wsgi进行Django depoyment

已安装应用程序中的“django.contrib.admin”未注释。你说“管理中间件”,但我找不到任何管理中间件-只有管理应用程序。然后我的手就正式用完了。laurent的回答很好,不过,安装的应用程序中的“django.contrib.admin”没有注释。你说“管理中间件”,但我找不到任何管理中间件-只有管理应用程序。然后我的手就正式用完了。laurent的回答很好。这是可行的,但正确的方法是使用
django.root
删除你的url,只留下django将开始的部分,这样你就可以移动你的站点,只需要更改
django.root
。这里的解释是:对不起,我的答案被切碎了,但我不得不停下来。。作为补充,在你的情况下是
/
,所以如果你去掉它,它会保持为空,医生说你必须在开头至少留下一行
/
,所以我删除了这行,也许有更好的方法。。。但这个似乎有效!您不需要django.root,甚至不需要“/”的封闭位置块。VirtualHost顶层的内容适用于/的URL。这是可行的,但正确的方法是使用
django.root
剥离URL,只留下django将开始的部分,这样您就可以移动站点,只需要更改
django.root
。这里的解释是:对不起,我的答案被切碎了,但我不得不停下来。。作为补充,在你的情况下是
/
,所以如果你去掉它,它会保持为空,医生说你必须在开头至少留下一行
/
,所以我删除了这行,也许有更好的方法。。。但这个似乎有效!您不需要django.root,甚至不需要“/”的封闭位置块。VirtualHost的顶层内容适用于/Anywhere的URL。