Posted by admin | Posted in python | Posted on 26-08-2010
0
python代码是缩进的,所以要注意格式,对缩进的要求,建议是4个空格,其实TAB、7个空格、1个空格,都是可以的,主要是要保持一致,总之最好用专业的IDE来开发,推荐UliPad,下面我提供了4.0的一些地址。
出现格式错误的提示是:IndentationError: unindent does not match any outer indentation level
这点经验留给新手们
UliPad 4.0
Project: http://code.google.com/p/ulipad
source version: http://ulipad.googlecode.com/files/ulipad.4.0.zip
windows exe version: http://ulipad.googlecode.com/files/ulipad.4.0.py25.exe
maillist: http://groups.google.com/group/ulipad
ulipad snippets site: http://ulipad.appspot.com (hosted by GAE)
Posted by admin | Posted in python | Posted on 01-07-2010
0
apache2.2虚拟机的配置
1、添加python模块引用:
LoadModule python_module modules/mod_python.so
2、创建一个虚拟机
<VirtualHost 127.0.0.15>
ServerName www.py.com
<Location "/">
SetHandler python-program
PythonPath "['D:/www/www/py'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonAutoReload Off
PythonDebug On
</Location>
</VirtualHost>
创建django 项目
1、django 可以svn到pytho的C:\Python25\Lib\site-packages\目录下,或者下载安装包来安装,该安装包与项目无关。
2、django-admin.py 是django的项目管理文件,创建项目时,CMD进入D:\www\www\py目录,输入
C:\Python25\Lib\site-packages\django\bin\django-admin.py startproject mysite
或者输入
C:\Python25\Scripts\django-admin.py startproject mysite
就可以建立mysite这个项目了
如果你还没启动服务器的话,请切换到你的项目目录里 (cd mysite ),运行下面的命令:
python manage.py runserver
参考资料:
http://wiki.thinkhole.org/howto:django_on_windows
http://djangobook.py3k.cn/chapter20/