编程与软件工程lincolnloop.com
Django 最佳实践
Django Best Practices
2009 — 2013,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
这是 Lincoln Loop 公司整理的 Django 最佳实践指南,涵盖项目布局、settings 配置、部署等开发规范。它在 2009 至 2013 年间多次登上 Hacker News 首页,是 Django 社区早期广为流传的参考文档。
为什么经久不衰:它沉淀了 Django 项目组织与部署的通用经验,其中关于配置管理、依赖安装的讨论至今仍是工程实践中的经典议题。
HN 评论精选
推荐几个进阶必备的 Django 工具和实践
再补充一些度过新手期后保持理智的技巧:部署前先用 South 做数据库迁移;用 Fabric 这类自动化部署工具,或 Chef/Puppet 这类更强大的工具;用 django-command-extensions 获得更好的调试器和其他便利功能。当然,根据具体项目,还有更多可视为必备的应用。
arocks查看英文原文
Some more tips to maintain your sanity once you are past the beginner level: * Use South before you start deploying * Use an automated deployment tool like Fabric or more powerful ones like Chef/Puppet * Get a better debugger and other niceties with django-command-extensions Of course, a lot more apps can be considered must have depending on what you are working on.
主张用环境变量代替多份 settings 文件
我不同意关于 settings 文件那一章。与其为不同环境维护多份 settings,不如让默认 settings 文件从 os.environ 读取各环境的修改,例如 STATIC_URL = os.environ.get('STATIC_URL', '/static/')。这样合理得多,不会陷入维护多份配置文件的混乱,也更容易解释。
flashingpumpkin查看英文原文
I've got to disagree with the chapter about settings files. Instead of maintaining multiple different settings for different environments, make your default settings file pull modifications for each environment from os.environ, e.g.: STATIC_URL = os.environ.get('STATIC_URL', '/static/') This is a lot saner and won't descend into a mess that is keeping multiple settings files around. It's also a lot easier to explain.
批评直接从远程源装依赖,建议本地化依赖
按文中推荐的方式使用 pip 是欠考虑的。这会让部署依赖:1. 可用的网络连接;2. 所有远程仓库在线;3. 没人动过远程仓库。第 3 点问题不大,但这三点都不受你控制,而且每次安装都重新下载依赖也很浪费。好在 pip 有 --find-links 选项,配合把所有依赖下载到本地,就能实现完全本地化的安装。
praptak查看英文原文
Using pip the way they recommend is careless. It makes your deployment dependent on: 1. a working network connection and 2. All the remote repositories being up. 3. nobody having messed with the remote repos. The 3. is admittedly less of a concern, but all 3. are beyond your control and re-downloading the dependencies on each install is wasteful. Fortunately pip has the --find-links option which, combined with having all dependencies downloaded locally makes it possible to have a fully local install.
推荐另一本更全面的 Django 实践书籍
我刚读完《Two Scoops of Django》,真希望刚开始写 Django 应用时就读过它。强烈推荐。
boolean查看英文原文
I just read Two Scoops of Django and wished I read it when I first started developing Django apps. Highly recommended. https://django.2scoops.org/ HN discussion: http://news.ycombinator.com/item?id=5074026
历次讨论
同类还值得读
开源应用架构
The Architecture of Open Source Applications
《开源软件架构》(AOSA)是一本在线免费书,邀请知名开源项目的作者亲自剖析其内部设计,涵盖 SQLAlchemy、LLVM、Audacity、Apache、Bash 等系统。
编程与软件工程上首页 9 次 · 2011–2024aosabook.org编辑精选编程语言简史:简短、不完整且多半错误
A Brief, Incomplete, and Mostly Wrong History of Programming Languages
一篇以戏谑、故意不准确的方式回顾编程语言史的博客文章,用夸张轶事和讽刺定义串起 Lisp、C、C++、Java、JavaScript、PHP 等语言。
编程与软件工程上首页 8 次 · 2009–2021james-iry.blogspot.comSQLite 是如何测试的
How SQLite is tested
SQLite 官方文档页,系统介绍 SQLite 的测试体系:多种测试方法(TCL 测试、模糊测试、回归测试、静态分析等)和海量测试用例,展示了这个小型开源项目如何靠极致测试获得…
编程与软件工程上首页 8 次 · 2009–2025sqlite.org编辑精选高级编程语言(2009)
Advanced programming languages (2009)
Matt Might 的经典文章,按用途推荐“高级编程语言”:如果追求就业就选主流语言,如果追求表达力、学术研究或创业,则推荐 Haskell、OCaml、Scala 等函数式语…
编程与软件工程上首页 8 次 · 2009–2022matt.might.net我的 Forth 与栈机器经历
Yosefk - My history with Forth & stack machines
作者以亲身经历回顾了使用 Forth 语言和栈式机器的历程:既赞叹其简洁优雅、代码量小、可自举的优点,也坦率指出栈操作在实际编程中的痛苦,以及 Forth 社区文化中的问题。
编程与软件工程上首页 8 次 · 2010–2024yosefk.com编辑精选