环境:windows xp sp2,apache,python,mod_python
参考链接
http://www.cnblogs.com/game-over/articles/891141.html
http://hi.baidu.com/gksw/blog/item/66e1e4ddf4d90cea77c638c6.html
http://thinkhole.org/wp/django-on-windows/
1. 安装django
运行-cmd打开命令提示框
输入 cd C:\Python25指向python目录,否则不能执行python命令
输入 python E:\test\PY\Django-1.0-alpha\setup.py install
会有一大堆结果自动安装(E:\test\PY\为个人的python工程目录后面是下载过来的包)
2. 先简单的测试一下。
命令提示符下,输入:python
然后输入import django
然后输入django.VERSION
我看到的是这样的:......
3. 在C:\Python25\Scripts可以看到django-admin.py了
4. 在c:\创建django目录,copy django-admin.py到该目录
执行 django-admin.py startproject myproject
创建了myproject
5. cd C:\python25 回到这里
执行 python c:\django\myproject\manage.py runserver
可以看到类似
Django version 0.9.1(SVN), using settings 'myproject.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C or CTRL-BREAK.
说明一切正常启动
6. 访问 http://localhost:8000/mysite可以看到 welcome to Django了
7. 在httpd.conf中写入
Alias /mysite C:/django/myproject
AddHandler mod_python .py
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE myproject.settings
PythonDebug On
PythonPath "['C:\django'] + sys.path"
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
即可以使用http://localhost/mysite/访问了
8. hello world
在myproject目录创建 helloworld.py
from django.http import HttpResponse
def index(request):
return HttpResponse('Hello, World!')
然后打开urls.py修改urlpatterns,加入一个pattern
(r'^mysite/', 'myproject.helloworld.index'),
9. 重启apache,打开http://localhost/mysite/
看到hello,world
django的书
djangobook.py3k.cn
www.djangobook.com
