2010-07-15 1 views
1

오늘 전체 프로덕션 서버에서 django를 구성하려고했습니다. 나는 mod_python을 사용한다. http : //beta.example.com을 열었을 때 사이트가 보이지만 http : //beta.example.com/admin 및 http : //beta.example.com/441/abc/가 작동하지 않습니다.Django + mod_python + apache : admin 패널 및 url이 작동하지 않습니다.

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. 

내 URL을 :

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'), 

) 

아파치 :

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> 

나는 무엇이 잘못되었는지 모르겠어요.

답변

2

확실하지.

+0

좋아요! 고마워요 :) –

+0

그게 효과가 있지만 옳은 방법은'django.root'를 사용하여 URL을 제거하는 것입니다. 장고가 시작될 부분 만 남겨두면 사이트를 이동할 수 있고'django 만 변경하면됩니다. 루트'. 여기에 설명되어 있습니다 : http://docs.djangoproject.com/en/dev/howto/deployment/modpython/?from=olddocs – laurent

+0

미안 해요 내 대답은 슬라이스지만 멈춰야했습니다 .. 보완하기 위해, 귀하의 경우에 은' /'만약 당신이 그것을 떼어 내면, 그것은 빈 상태를 유지하고 의사는 처음부터 적어도'/'를 남겨 두어야한다고 말했기 때문에 아마 그 행을 삭제했을 것입니다, 아마도 더 좋은 방법이있을 것입니다 ... 그러나 이것은 작동하는 것처럼 보입니다! – laurent

0

난 그냥 던지고있어,하지만 당신은 설정 파일에 장고 관리 미들웨어를 활성화해야합니다. 거기에 있지만 즉시 상자 밖으로 댓글을 달았습니다. 당신이 그 일을했다면 나는 당신의 문제가 뭔지 전혀 모른다.

PythonOption django.root /

그것이 작동하도록 : 그 문제를 해결할 수 있지만, 장고 내 site.conf에 내가 선을 언급 한 경우

+0

INSTALLED_APPS의 'django.contrib.admin'이 주석 처리되지 않았습니다. 당신은 '관리 미들웨어'라고 말하지만 어떤 관리자 미들웨어도 찾을 수 없습니다 - 오직 관리자 앱. –

+0

그러면 내 손이 공식적으로 전부 펼쳐집니다. 로랑의 멋진 대답. –

2

정말 배포를 위해 mod_python을 사용하고 싶지 않습니다. 난 장고 depoyment mod_wsgi로 이동하는 것이 좋습니다.