Zope的没落,Django的崛起
django python
1.00
zope python
0.92
一图胜千言,Zope糟糕的文档,不友好的社区注定了它的没落,虽然Zope有很多优秀的地方,但比起Django在很多地方做的太过复杂了。学习Django的过程中有着过去从Zope身上从来没有得到的愉悦,Django为什么会流行? 如果你喜欢这篇文章,欢迎 订阅我的 RSS feed!
django python
1.00
zope python
0.92
一图胜千言,Zope糟糕的文档,不友好的社区注定了它的没落,虽然Zope有很多优秀的地方,但比起Django在很多地方做的太过复杂了。学习Django的过程中有着过去从Zope身上从来没有得到的愉悦,Django为什么会流行? 如果你喜欢这篇文章,欢迎 订阅我的 RSS feed!
说明: 虽然本文是针对django而写,但对于其他python框架应同样适用。 浪点现在只支持mod_python这一种部署方式了,详细了解mod_python请参考mod_python 官方手册翻译
构造虚拟环境:
$ python virtualenv.py –no-site-packages sandbox
virtualenv.py下载地址
浪点默认装了一些有用的Python包,如PIL、lxml等,这些依赖c的包是你无法自己在virtualenv环境中使用的,不过好在直接拷贝过来就可以用了
$ cp /usr/share/pyshared/* -r sandbox/lib/python2.6/site-packages/
切换到虚拟环境,安装自己的包
source sandbox/bin/activate easy_install Django
自定义Pythonhandler:
这里做的最核心的事情就相当于你运行source bin/activate,把Python运行环境切换为你自己的虚拟环境。
#myve.py activate_this = ‘/home/virtualhost/${username}/sandbox/bin/activate_this.py’ execfile(activate_this, dict(__file__=activate_this)) from django.core.handlers.modpython import handler
配置 .htaccess
注意这里的mysite和project。PythonInterpreter可随意写,只要别和其他目录下重复就行了,不写也可以
SetHandler python-program PythonPath "['/home/virtualhost/${username}/sandbox/bin', '/home/virtualhost/${username}/xmu.me/public_html/${mysite}/'] + sys.path" PythonHandler myve SetEnv DJANGO_SETTINGS_MODULE {project}.settings PythonDebug On PythonInterpreter wayhome
现在你就可以访问你的django程序了,have fun :) 如果你喜欢这篇文章,欢迎 订阅我的 RSS feed!
Technorati Tags: python, django
今天终于拿到了国内的第一本Django中文书《Django web开发指南》。激动之余,也有些小小的失望。
坊间一直流传本书是基于Django 1.0的,不过就书中的例子来看,还是基于旧版本的Django.因此笔者将根据自己的学习进度,将一些变动的地方在这里一一刊出。
第二章 51页
urls.py的修改类似于这样:
# Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() urlpatterns = patterns(”, # Example: # (r’^mysite/’, include(’mysite.foo.urls’)), # Uncomment the admin/doc line below and add ‘django.contrib.admindocs’ # to INSTALLED_APPS to enable admin documentation: (r’^admin/doc/’, include(’django.contrib.admindocs.urls’)), # Uncomment the next line to enable the admin: (r’^admin/(.*)’, admin.site.root), )
设置admin应用的时候,可以按书中的方法。也可以创建文件mysite/blog/admin.py,在其中添加:
from mysite.blog.models import BlogPost from django.contrib import admin
admin.site.register(BlogPost)
第二章 57页
mysite/urls.py和mysite/blog/urls.py中都不要括号外面的那个url方法,类似这样:
(r’^blog/’,include(’mysite.blog.urls”)) 如果你喜欢这篇文章,欢迎 [...]