摘要: return HttpResponseRedirect(reverse(index)) 阅读全文
posted @ 2009-12-11 14:34 kid的笔记本 阅读(490) 评论(0) 推荐(0) 编辑
摘要: classEvent(models.Model):user=models.ForeignKey(User) def__unicode__(self): returnself.user.username+u'的事件' 注意 user.username 阅读全文
posted @ 2009-12-11 10:35 kid的笔记本 阅读(228) 评论(0) 推荐(0) 编辑
摘要: 把django-admin.py copy 到对应的项目下,结果报错:errors happened while running xgettext on __init__.py ,不应该啊,俺是按照http://docs.djangoproject.com/en/dev/topics/i18n/#gettext-on-windows 一步一步做的么~~~最后google了半天,才知道,得重启cmd... 阅读全文
posted @ 2009-12-07 16:27 kid的笔记本 阅读(262) 评论(0) 推荐(0) 编辑
摘要: if not 'request' in context: 阅读全文
posted @ 2009-12-04 10:28 kid的笔记本 阅读(83) 评论(0) 推荐(0) 编辑
摘要: http://ddkangfu.blog.51cto.com/311989/77265/ 阅读全文
posted @ 2009-12-02 18:06 kid的笔记本 阅读(109) 评论(0) 推荐(0) 编辑
摘要: map((lambda x:x+1), x)def true(): return True; <=> lambda :True>>>a = lambda : True>>>a() def add(x, y): return x + y; <=> lambda x, y: x + y >>>a = lambda x, y:... 阅读全文
posted @ 2009-12-01 15:17 kid的笔记本 阅读(217) 评论(0) 推荐(0) 编辑
摘要: http://www.kuangxuqing.com/2008/12/25/form-in-django.6693.html 阅读全文
posted @ 2009-11-27 14:17 kid的笔记本 阅读(144) 评论(0) 推荐(0) 编辑
摘要: import tracebacks = traceback.extract_stack()得知被谁调用 阅读全文
posted @ 2009-11-25 09:44 kid的笔记本 阅读(516) 评论(0) 推荐(0) 编辑
摘要: django还有一种通过对象访问相关联表数据的方法,即用_set。但是这种方法只能是相关类访问定义了关系的类(主键类访问外键类)。如:b.entry_set.all() #b是一个blog对象另外还有就是如果Entry中blog属性的定义如果改成这样:blog=ForeignKey(Blog,related_name='entries')这样的话就可以像下面这样通过blog对象得到entry对象的... 阅读全文
posted @ 2009-11-24 14:00 kid的笔记本 阅读(1198) 评论(0) 推荐(0) 编辑
摘要: 使用函数 <tt class="docutils literal"><span class="pre">ugettext()</span></tt> 来指定一个翻译字符串。 作为惯例,使用短别名 <tt class="docutils literal"><span class="pre">_</span></... 阅读全文
posted @ 2009-11-24 09:47 kid的笔记本 阅读(984) 评论(0) 推荐(0) 编辑