Django Book 翻译
菜单>:
TOC
返回
原文:
The preferred way to do this is by giving your model custom methods or custom manager methods that execute queries. Although theres nothing in Django that *requires* database queries to live in the model layer, this approach keeps all your data access logic in one place, which is smart from a code organization standpoint. For instructions, see Appendix B..
翻译:
解决这个问题的比较好的方法是,给模块写一个自定义的方法或者管理器方法来执行查询。尽管在Django中,数据库查询在模块中没有任何存在的 *必要性* ,但是这种解决方案使你的数据访问在逻辑上保持一致,而且从组织代码的角度讲也更灵活。操作指南见附录B。
备注:
译者: