摘要: 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) 编辑
摘要: http://www.ibm.com/developerworks/cn/opensource/os-django-admin/index.html重写 AdminModel 方法使用 signals 向 admin 添加功能def notify_admin(sender, instance, created, **kwargs): if created: subject = 'New user ... 阅读全文
posted @ 2009-11-24 09:16 kid的笔记本 阅读(436) 评论(0) 推荐(0) 编辑
摘要: class QuestionOptions(admin.ModelAdmin): inlines = [ ChoiceInline,#可以让ChoiceInline这个model在Question界面里显示 ]class ChoiceInline(admin.TabularInline): ........ 阅读全文
posted @ 2009-11-24 09:02 kid的笔记本 阅读(784) 评论(0) 推荐(0) 编辑
摘要: http://www.javaeye.com/wiki/django-freshman/1993-django-freshman-2-2class ChoiceInline(admin.TabularInline): 阅读全文
posted @ 2009-11-24 08:57 kid的笔记本 阅读(186) 评论(0) 推荐(0) 编辑