6.02 Django

Django

Django (发音:姜够)是一个广泛使用的Python web框架,号称“自带排炮”,其理念是开发web应用的功能模块应该包含在框架内,而不是调用外部库。

Official Django logo. Trademark Django Software Foundation.

比如说,验证authenticationURL routing,object-relational mapper (ORM),以及 database schema migrations (Django 1.7起) 都包含在django framework里。作为对比,比如要在Flask里使用,需要第三方的Flask-Login库实现验证。

自带火炮哲学和通过外部扩展哲学,是设计框架的两种不同理念。没有哪种理念一定优于另一种。

为什么Django是一个好的选择?

Django项目经过10多年发展,功能强大,社区繁荣,文档丰富,参考资料众多,是初学web框架的一个非常好的入门。各地都有活跃的Django社区。

Django书籍和教程

Django已经发展了10多年,确保看到不过时的书籍和教程。最新版本是1.11,这本书current Django books 介绍as of Django 1.9。

Django视频

最佳Python视频里有一节专门讲Django视频

Django迁移

  • Paul Hallett wrote a detailed Django 1.7 app upgrade guide on the Twilio blog from his experience working with the django-twilio package.
  • Real Python’s migrations primer explores the difference between South’s migrations and the built-in Django 1.7 migrations as well as how you use them.
  • Andrew Pinkham’s “Upgrading to Django 1.7” series is great learning material for understanding what’s changed in this major release and how to adapt your Django project. Part 1, part 2 and part 3 and part 4 are now all available to read.
  • Django migrations without downtimes shows one potential way of performing on-line schema migrations with Django.

Channels in 1.9+

Channels are a new mechanism in Django 1.9 provided as a standalone app. They may be incorporated into the core framework in 2.0+. Channels provide “real-time” full-duplex communication between the browser and the server based on WebSockets.

Django测试

Django与Angular (Djangular) 资源

Django ORM 资源

Django comes with its own custom object-relational mapper (ORM) typically referred to as “the Django ORM”. Learn more about the Django ORM on the Python object-relational mappers page that includes a section specifically for the Django ORM as well as additional resources and tutorials.

静态和多媒体文件

部署和处理静态和多媒体文件对Django开发新手来说不容易。下面资源讲述如何处理:

开源Django实例项目

  • Browser calls with Django and Twilio 展示如何用Django和Twilio Client 把用户的浏览器变成一个电话。相当酷!
  • Txt 2 React 一个Django项目,允许用户在演示时输入文本。
  • Openduty 一个网站状态监测,类似PagerDuty
  • Courtside 是一个体育网站应用
  • These two Django Interactive Voice Response (IVR) system web application repositories part 1 and part 2 show you how to build a really cool Django application. There’s also an accompanying blog post with detailed explanations of each step.
  • Taiga 是一个项目管理工具,Django做后端,AngularJS做前端。

Django项目模板

项目模板,不是模板引擎template engine,为Django生成格式化的代码

Django学习清单

  1. 安装 Django 到你的本地开发环境
  2. 完成最初的教程 “polls” tutorial
  3. 做一些简单应用
  4. 开始做你自己的项目。多参考官方文档official documentation
  5. 阅读 2 Scoops of Django 了解Django优良实践
  6. 到 部署环节,把你的Django应用部署到网上

发表评论

电子邮件地址不会被公开。 必填项已用*标注