|
2.0/chapter05/#148 |
2009-11-05 08:24:35
|
|
|
|
2.0/chapter05/#146 |
2009-11-05 08:24:22
|
|
|
|
2.0/chapter05/#142 |
2009-11-05 08:24:09
|
|
|
|
2.0/chapter05/#136 |
2009-11-05 08:23:56
|
|
|
|
2.0/chapter05/#140 |
2009-11-05 08:23:37
|
|
|
|
2.0/chapter05/#134 |
2009-11-05 08:22:00
|
|
|
|
2.0/chapter05/#130 |
2009-11-05 08:21:45
|
|
|
|
2.0/chapter02/#268 |
2009-11-22 15:47:15
|
为此, 转到<literal>django-admin.py</literal>所在的目录,运行命令<literal>cd /usr/local/bin</literal>。<literal>chmod +x django-admin.py</literal> |
|
|
2.0/chapter10/#58 |
2009-11-04 13:37:48
|
Django<emphasis></emphasis>关心数据库中是否存在未被模型表示的表格。
|
|
|
2.0/chapter05/#509 |
2009-11-05 09:38:49
|
|
|
|
2.0/chapter10/#194 |
2010-01-05 16:03:27
|
注意,这个方法使用了self.filter(),此处self指manager本身
|
|
|
2.0/chapter10/#193 |
2010-01-05 16:02:42
|
我们建立了一个BookManager类,它继承了django.db.models.Manager.只拥有一个title_count()方法用来做统计.
|
|
|
2.0/chapter07/#474 |
2009-11-05 21:37:37
|
指定显示标题
|
|
|
2.0/chapter07/#459 |
2009-11-05 21:36:15
|
我们希望<literal> message</literal> 字段有一个额外的校验,我们增加一个<literal> clean_message()</literal> 方法到<literal> Form</literal> 类:
|
|
|
2.0/chapter09/#256 |
2010-01-02 14:30:15
|
如果你正在编写一个模板而不知道是否要关闭自动转意,那就为所有需要转意的变量添加一个<literal> escape</literal> 过滤器.
|
|
|
2.0/chapter09/#236 |
2010-01-02 14:33:45
|
为了控制模板的自动转意,用标签autoescape来包装整个模板(或者模板中常用的部分),就像这样
|
|
|
2.0/chapter09/#239 |
2010-01-02 14:34:45
|
autoescape 标签有两个参数on和off
|
|
|
2.0/chapter09/#244 |
2010-01-02 14:35:31
|
auto-escaping 标签的作用域不仅可以影响到当前模板还可以通过include标签作用到其他标签,就像block标签一样
|
|
|
2.0/chapter09/#248 |
2010-01-02 14:36:11
|
由于在base模板中自动转意被关闭,所以在child模板中自动转意也会关闭.因此,在下面一段HTML被提交时,变量greeting的值就为字符串Hello!
|
|
|
2.0/chapter09/#256 |
2010-01-02 14:37:02
|
如果你正在编写一个模板而不知道是否要关闭自动转意,那就为所有需要转意的变量添加一个escape过滤器.
|
|
|
2.0/chapter09/#264 |
2010-01-02 14:37:30
|
所有字符常量没有经过转义就被插入模板,就如同它们都经过了safe过滤
|
|
|
2.0/chapter09/#265 |
2010-01-02 14:38:16
|
这是由于字符常量完全由模板作者决定,因此编写模板的时候必须确保文本的正确性.
|
|
|
2.0/chapter09/#253 |
2010-01-02 15:34:25
|
通常,模板作者没必要为自动转意担心.
|
|
|
2.0/chapter09/#257 |
2010-01-02 15:37:55
|
当自动转意开启时,使用escape过滤器似乎会两次转意数据,但其实没有任何危险.因为escape过滤器不作用于被转意的变量.
|
|
|
2.0/chapter10/#184 |
2010-01-05 16:00:42
|
例如,我们为Book模型定义了一个title_count()方法,它需要一个关键字,返回包含这个关键字的书的数量.
|
|
|
2.0/chapter05/#682 |
2009-11-03 20:39:15
|
类似的,你可以用python的range-slicing语法来取出数据的特定子集
|
|
|
2.0/chapter09/#428 |
2010-03-30 17:21:53
|
在编译的模板形式中,这个模板表示节点的列表:
|
|
|
2.0/chapter11/#115 |
2009-12-26 23:17:50
|
在模板内部,通用视图使用在<3>template_object_name<4> 后面添加<1>_list<2>的方法来创建变量表示项目集合。
|
|
|
2.0/chapter08/#413 |
2010-01-01 17:22:14
|
优化后的代码和前面的功能一样,但是减少了代码冗余
|
|
|
2.0/chapter10/#264 |
2010-01-05 17:08:38
|
更不要把你的视图代码和django.db.connection语句混杂在一起,把它们放在自定义模型或者自定义manager方法中是个不错的主意.
|
|
|
2.0/chapter05/#130 |
2009-11-12 12:26:39
|
<literal> postgresql</literal> |
|
|
2.0/chapter08/#414 |
2010-01-01 17:25:09
|
现在我们建立了一个漂亮,通用的函数requires_login()来帮助我们修饰所有需要它来验证的视图
|
|
|
2.0/chapter03/#551 |
2009-11-07 02:53:17
|
幸运的是,Django内建有一个简单又强大的模板处理引擎来让你分离两种工作:
|
|
|
2.0/chapter05/#134 |
2009-11-12 12:27:07
|
<literal>psycopg</literal> version 1.x,
<reference name="http://www.djangoproject.com/r/python-pgsql/1/" refuri="http://www.djangoproject.com/r/python-pgsql/1/">http://www.djangoproject.com/r/python-pgsql/1/</reference>.
|
|
|
2.0/chapter08/#410 |
2010-01-01 17:29:08
|
现在,我们可以从views中去掉if not request.user.is_authenticated()验证.我们可以在URLconf中很容易的用requires_login来包装实现.
|
|
|
2.0/chapter05/#136 |
2009-11-12 12:27:27
|
<literal>postgresql_psycopg2<2> |
|
|
2.0/chapter05/#136 |
2009-11-12 12:27:46
|
<literal>postgresql_psycopg2</literal> |
|
|
2.0/chapter08/#407 |
2010-01-01 17:34:53
|
函数requires_login,传入一个视图函数view,然后返回一个新的视图函数new_view.这个新的视图函数new_view在函数requires_login内定义
|
|
|
2.0/chapter05/#140 |
2009-11-12 12:28:04
|
<literal>psycopg</literal> version 2.x,
<reference name="http://www.djangoproject.com/r/python-pgsql/" refuri="http://www.djangoproject.com/r/python-pgsql/">http://www.djangoproject.com/r/python-pgsql/</reference>.
|
|
|
2.0/chapter08/#408 |
2010-01-01 17:40:14
|
处理request.user.is_authenticated()这个验证,从而决定是否授权原来的view函数
|
|
|
2.0/chapter08/#408 |
2010-01-01 17:41:26
|
处理request.user.is_authenticated()这个验证,从而决定是否执行原来的view函数
|
|
|
2.0/chapter05/#130 |
2009-11-12 12:26:08
|
<literal>postgresql<2> |
|
|
2.0/chapter02/#332 |
2010-01-10 04:16:01
|
好了,你已经安装好一切所需, 并且开发服务器也运行起来了,你已作好了准备可以继续 <reference name="learn the basics" refuri="../chapter03/">学习基础知识---用Django伺候网頁</reference> , 这一章的内容。
|
|
|
2.0/chapter10/#268 |
2010-01-05 17:10:28
|
然后这样使用:
|
|
|
2.0/chapter10/#135 |
2009-11-23 21:21:07
|
删除字段,然后重新启动你的web服务器
|
|
|
2.0/chapter09/#433 |
2010-03-30 20:05:28
|
变量节点
|
|
|
2.0/chapter10/#133 |
2009-11-23 21:19:57
|
删除字段,仅仅只要以下几步
|
|
|
2.0/chapter10/#132 |
2009-11-23 21:17:43
|
从Model中删除一个字段要比添加容易得多
|
|
|
2.0/chapter08/#254 |
2009-12-28 21:57:06
|
额外的选项
|
|
|
2.0/chapter08/#305 |
2009-12-28 21:57:53
|
(这是短路逻辑。)
|
|