Two Scoops of Django

Daniel Greenfeld, Audrey M. Roy

出版时间

2013-04-16

ISBN

9781481879705

评分

★★★★★
书籍介绍
这不本教你从零搭建第一个 Django 项目的入门书,而是给'教程读完之后'的人看的实战手册。它把两位作者多年踩坑攒下的最佳实践,浓缩成一句好记的口诀:Fat Models, Helper Functions, Thin Views, Stupid Templates——模型多担待,视图别臃肿,模板傻瓜化。书里几乎每一页都是一个可落地的具体建议:用 settings 目录而非单一配置文件管理环境,用环境变量藏好密钥而非写死在代码里,用 Meta.fields 精确控制暴露字段,以及被读者反复点名的 CBV(基于类的视图)。它不追求系统性的工程讲解,反而带着作者鲜明的碎碎念式主观判断,甚至有些观点颇具争议。正因如此,它更适合已有一定 Django 基础、想给现有项目做'体检和升级'的开发者,而非纯新手。
作者简介
Daniel Greenfeld and Audrey Roy are best known for their open-source community leadership work on the following initiatives: DjangoPackages.com and the OpenComparison framework. We ran the largest sprint at PyCon 2011. PyLadies, a women's outreach/mentorship group. Nurturing the group was basically a 2nd fulltime job for us in 2011. The first ever PyCon Philippines, a 300-person conference about the Python programming language held in the Philippines. The LA Open Source Hackathon event series, which brings together open-source developers from different programming backgrounds. They do Python and Django development and run a small Python/Django consulting shop called Cartwheel Web.
AI导读
核心看点
  • 汇集Django最佳实践,涵盖架构设计与代码规范
  • 详解胖模型瘦视图模式,提升代码可维护性
  • 提供配置分离、路径管理等实战技巧与代码片段
读者共识
  • 干货满满,实战经验丰富,值得项目前阅读
  • CBV讲解精彩,模型与模板最佳实践备受推崇
  • 作者文笔流畅,虽碎片化但精华浓缩,好评多
精彩摘录
  • "Fat Models, Helper Functions, Thin Views, Stupid Templates"
  • "When writing code, it’s important to do so in such a way that it’s easier to move, rename, and version your work. In Python, relative imports remove the need for hardcoding a module’s package, separating individual modules from being tightly coupled to the architecture around them."
  • "Instead of having one settings.py file, with this setup you have a settings/ directory containing your settings files. It will typically contain something like the following: settings/ __init__.py base.py local.py staging.py test.py production.py One of the causes of the local_settings anti-pattern "
  • "We find the the cleanest way to set PROJECT_ROOT is with Unipath (http:// pypi.python.org/pypi/Unipath/), a Python package that does elegant, clean path calculations:  # At the top of settings/base.py from unipath import Path PROJECT_ROOT = Path(__file__).ancestor(3) MEDIA_ROOT = PROJECT"
用户评论
实践出真知,这本书值得在开始项目前一看。
Django进阶的一本小书,class-base view和function-base view对比讲的很好,还有model、templates的最佳实践,很棒的一本书!
CBV太赞了
在标准化设计上确实不错...不知道为什么分这么低,表这样啊
常识……
本来想随便读读来复习Django。越读越欲罢不能。Django知识+基础架构+Best Practice,干货满满啊。不管是不是学Django,都值得看一看。
看的最新的1.8版本,依然写的不错~
实战经验大赞
书名很有意思,两勺姜戈。分章讲解了 Django 应用的各种 Best Practices。上次接触 Django 的时候是1.3,那时好像还没有 CBV,这本书比较适合有 Django 基础的人阅读,基于 Python 自身的可读性,我读的很快基本上走马观花,有了个大概的了解,再找本其他的书读一读吧,Pro Django 看上去不赖。
下载
收藏