django配置apache model_python

网络整理 - 07-26

Blog解释得很明白,我下面的这些步骤得到了验证。

1

修改的配置行

# Django settings for myproject project.

'''

将相对路径改为绝对路径。主要有:

MEDIA_ROOT

TEMPLATE_DIRS

STATIC_PATH

'''

# Absolute path to the directory that holds media.

# Example: "/home/media/media.lawrence.com/"

MEDIA_ROOT = 'c:/django/myproject'

STATIC_PATH = 'c:/django/myproject/media'

TEMPLATE_DIRS = (

    # Put strings here, like "/home/html/django_templates".

    # Always use forward slashes, even on Windows.

    'c:/django/myproject/templates',

)

增加的配置行

 mysite目录路径: c:/django/myproject

但是对于PythonPath,必须设置成这个目录的上一级目录!

# this site url::80/mysite/

<Location "/mysite/">

    SetHandler python-program

    PythonPath "sys.path+['c:/django']"

    PythonHandler django.core.handlers.modpython   

    SetEnv DJANGO_SETTINGS_MODULE myproject.settings

    PythonInterpreter mysite

    PythonDebug On

</Location>

增加的配置行

#Alias /site_media 是用来将 myproject的静态文件设置一个 URL 访问的别名。

Alias /site_media c:/django/myproject/media

<Location "/site_media/">

       SetHandler None

</Location>

 

#Alias /media 是将 Django Admin 的静态文件设置一个 URL 的访问别名。

Alias /media c:/Django-0.95/django/contrib/admin/media

<Location "/media/">

       SetHandler None

</Location>

 

# file types we want to serve statically

# case insensative match

<LocationMatch "(?i)\.(jpg|gif|png|txt|ico|pdf|css|jpeg)$">

       SetHandler None

</LocationMatch>

即可。