How to install Django

How to install Django

Downloading these software and then installing them as follow:

python:  http://www.python.org/ftp/python/2.4.3/python-2.4.3.msi

PIL for py2.4:  http://www.pythonware.com/products/pil/

Django:  http://media.djangoproject.com/releases/0.95/Django-0.95.4.tar.gz

apache:  http://apache.justdn.org/httpd/binaries/win32/apache_2.0.58-win32-x86-no_ssl.msi

mod_python:  http://apache.justdn.org/httpd/modpython/win/3.2.8/mod_python-3.2.8.win32-py2.4.exe

 

you can also find them as attachments in this page.

 

Entering Django-0.95.4 directory

Using 'python ez_setup.py' command to check whether 'setuptool' is existent or not, if it is not existent, then it will download automatically from internet.

 

Then installing Django

Using 'python setup.py install' command to install Django to site-package directory and configure the sys.path file.

You can also check it out in terminal using:

import sys

print sys.path

 

Checking 'mod_python.so' out in 'D:\Program Files\Apache Group\Apache2\modules' directory

 

Modifying appach conf/httpd.conf file

Adding following things:

 

'LoadModule python_module modules/mod_python.so'

 

<Directory "D:/Program Files/Apache Group/Apache2/htdocs/test">

    AddHandler mod_python .py

  PythonHandler pythonTest

  PythonDebug On

</Directory>

 

Creating a ‘pythonTest.py’ file in the test directory, like this(paying more attention on code formatting):

 

from mod_python import apache
def handler(req):
       req.content_type = 'text/plain' 

        req.write("Hello World!\n")
        return apache.OK

 

 

 

 

Restart appach

Using following address:

http://127.0.0.1/test/pythonTest.py

 

'Hello World!' appears on the page.

 

 

Next, creating a django project.

 

Entering D:\Program Files\Python24\Scripts directory

Using 'django-admin.py startproject newtest' command to create a new django project.

 

Cutting the newtest directory and then pasting in D:\Program Files\Python24\Lib\site-packages directory

 

Modifying appach conf/httpd.conf file

<Location "/newtest/">  

    SetHandler python-program  

    PythonPath "sys.path+['D:/Program Files/Python24/Lib/site-packages/newtest']" 

    PythonHandler django.core.handlers.modpython  

    SetEnv DJANGO_SETTINGS_MODULE newtest.settings

    PythonDebug On  

</Location> 

 

Restart appach

Using following address:

http://127.0.0.1/newtest/

 

It works!

 

LOL 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值