Django 配置

//安装时的一些信息,贴在这里吧
Win2003
Apache /2.2.4
Django-0.96.1 框架
Python 2.5
Mod_python mod_python-3.3.1.win32-py2.5-Apache2.2.exe
MySQL_python-1.2.2-py2.5-win32
注意:
Django-0.95.2 (DEFAULT_VERSION = "0.6c3") 在用此版本时需更改 ez_setup.py 文件中的此处
pythonWin 2.5.1 编辑器

mod_python 安装
过在 Apache 的配置文件 ( 通常称为 httpd.conf 或者 apache.conf) 里面加入如下一行,来载入模块:
LoadModule python_module libexec/mod_python.so
A
<Directory /some/directory/htdocs/test>

AddHandler mod_python .py


PythonHandler mptest


PythonDebug On

</Directory>
测试文件
from mod_python import apache

def handler(req):


req.write("Hello World!")


return apache.OK

将你的浏览器指向 mptest.py 所在的 URL; 你将会看到 "Hello World!".

B
<Directory "E:/php/AppServ/www">

AllowOverride FileInfo


AddHandler mod_python .py


PythonDebug On


SetHandler mod_python


PythonHandler mod_python.publisher

</Directory>
测试页面前台
<html>
    请填写下面的回馈表单 :

<form action="form.py/email" method="  POST">

          用户名 :
<input type="text" name="name"><br>

          电子邮件 :
<input type="text" name="email"><br>



意见 :
<textarea name="comment" rows=4 cols=20></textarea><br>


<input type="submit">



<body> <a href="./form2.html" target=_blank>
第二首页 </a>

<a href="./form2.html" >
第三首页 </a>

</form>

</html>

测试页面后台
from mod_python import apache
def email(req,comment="NOTHING",name ="1",email="2"):

return "I am saying %s" % name + "I am saying %s"%email + "I am saying % s"%comment

   注意:不要输出 tuple 只输出单个变量就不会出现 unicode


二者似乎不可共存 , 原因未知

Django-0.96.1 安装:
Django-0.96.1.tar 解压
运行里面的 setup.py
Cmd -&gt;python setup.py install( 相应文件夹 )
Cmd -&gt; django-admin.py startproject website ( 比如 E:  )
C md -&gt;E:/website&gt;python manage.py runserver (启此服务)
查看 http://localhost:8000/页面 有成功的提示 “It worked!”
修改 urls.py
from django.conf.urls.defaults import *   
urlpatterns = patterns('',   
# Example:   
# (r'^mysite/', include('mysite.apps.foo.urls.foo')),   
   
# Uncomment this for admin:   
# (r'^admin/', include('django.contrib.admin.urls')),   
)   

注意:在应用 0.95.2 版本时出现此错误
'function' object has no attribute 'rindex'
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值