加载中

Python developers have a big pool of frameworks to choose from for their web projects. However, Django, without a shred of doubt, has become the most popular web framework among Python developers world over. Through this blog, I am throwing light on why Python developers prefer Django to other popular Python web frameworks, such as Flask, Pyramid, Tornado, Bottle, Diesel, Pecan, Falcon, and many more.

对于 Python 开发者来说,web 开发框架真可谓玲琅满目。然而 Django , 毋庸置疑的成为最受青睐的 web 框架。通过本篇博客,我来为大家讲解下为什么相比 Flask、Pyramid、Tornado、Bottle、Diesel、Pecan、Falcon 这些流行的 Python web 框架,Python 开发者更倾向于选择 Django。

Before jumping on to the virtues of Django, let’s understand in brief what a web framework is

A web framework is a code library that makes it easier for developers to build dynamic websites, web applications and web services. It’s a known fact that every site has a common set of functionality (like handling sessions, data validation, etc) that you need to re-write each time you create a website. This makes the task mundane and tedious. However, using a web framework ends your plight of re-writing common set of functionalities each time you create a website, resulting in faster development. In a nutshell, web frameworks ease web development life.

If you want to dive deep into web frameworks and their benefits, click here.

再大肆宣扬Django之前,让我们简单了解一下web框架

Web框架是一个代码库,使开发人员更容易构建动态网站、Web应用程序和Web服务。 众所周知的是,每个网站都有一些通用的功能(如处理会话,数据验证等等),一些您每次创建网站时都需要编写的功能。 这使开发任务平淡乏味。 然而,使用Web框架可以让您每次创建网站都需要重新编写通用功能代码的困境结束,从而实现更快的开发。 简而言之,Web框架可以简化Web开发。

如果您想深入了解Web框架及其优点,请点击此处

Why Django is the Best Web Framework for Python Developers


Django is a high-level, MVC-style, open-source collection of libraries written in Python. Django, also called “the framework for perfectionists with deadlines," was originally designed for news sites as it allows developers to write database-driven web applications without having to start coding from scratch.

Besides faster completion of common web development tasks, Django helps keep the design clean and pragmatic. Django is the best place for new Python web developers as the official documentation and tutorials are some of the best in software development.

The tech market is flooded with a gamut of web frameworks, but Django sits nicely at the top when it comes to the most popular server-side web frameworks. The motto behind designing Django was simple: Don’t repeat yourself. Django is written in Python, therefore emphasizes efficiency improvement by minimizing the hassle of writing too much code. Cloud platform support makes Django even a more popular choice for web development.

为什么Django是Python开发者的最佳选择

Django是一个Python编写的,高级的,MVC风格的开源库。 Django也被称为“完美主义者的最终框架”,它最初是为新闻网站设计的,因为它允许开发人员编写数据库驱动的Web应用程序,而无需从头开始编码。

除了更快完成常见的Web开发任务,Django还可以保持设计干净且实用。 Django是Python Web开发新人的最佳选择,因为官方文档和教程是几个(同类)软件开发框架中最好的。

技术市场充斥着一系列网络框架,但Django在最受欢迎的服务器端Web框架里处于顶峰位置。设计Django背后的座右铭很简单:避免重复。 Django是用Python编写的,因此其减少了太多中间层代码并突出提高了效率。Django可以支持云平台,使其成为Web开发中更受欢迎的选择。

Key Features of Django

  • Django Comes with “Batteries-Included”


That Django is based on ”batteries-included” philosophy, you need not to use separate libraries to implement common functionalities, like authentication, URL routing, a templating system, an object-relational mapper (ORM), and database schema migrations. If you are using or have used Flask, you must have noticed that it calls for a separate library like Flask-Login to perform user authentication. Such is not the case with Django.

Django主要特点

  • Django“自备军需”(Batteries-Included)

Django基于“自备军需”的理念,您不必使用单独的库来实现常见功能,例如身份验证URL路由模板系统对象关系映射器(ORM)数据库模型迁移。 如果您正在使用或曾经用过Flask,您一定注意到了它需要调用其他库,如Flask-Login来执行用户身份验证。 Django不是这样。

  • Free API

With Django, it’s easy to generate a Python API based on your models. No additional coding required as a simple command is good enough to begin generating APIs.

  • Unique Admin Interface


You can have information on your site from outside contributors even before the site is completely built. Such is the power of Django. The framework empowers you to quickly and easily generate an administration site straight from an application's models.

  • 自由的API

使用Django,很容易根据您的模型生成Python API。 只需一个简单的命令,不需要额外的编码就足以开始生成API了。

  • 独特的管理页面

即使在网站完全构建之前,您也可以从外部贡献者处获取有关信息。 这就是Django的力量。 该框架使您能够快速轻松地从应用模型生成管理站点。

  • Code Layout

In contrast to most web frameworks, Django makes it easier to plug new capabilities in your product by using things called applications. As a result, developers feel encouraged to write code that is self contained.

  • Django’s ORM Takes Care of Databases


Django’s Object Relational Mapper (ORM) takes care of databases. So, no hassles of dealing with the Structured Query Language (SQL), which is mostly used to query the database for the data needed. Unlike many other Python frameworks that directly work on the database via SQL, Django developers have a unique option to manipulate the corresponding Python model object. Django works out-of-the-box with relational database management systems like PostgreSQL, MySQL, SQLite, and Oracle.

Click here to learn the basics of data management with Django and its ORM.

  • 代码设计

与大多数 Web 框架相反,Django 通过使用称为 app 的东西,更容易地将新功能添加到产品中。 因此,开发者可以感受到 Django 鼓励大家编写模块化的代码。

  • Django对ORM的完善支持

Django的对象关系映射 (ORM) 对数据库进行了完善的支持。所以,它用于查询数据库所需的数据时,没有处理结构化查询语言(SQL)的麻烦。 与许多通过SQL直接在数据库上工作的Python框架不同,Django开发人员有一个独特的选择来操纵相应的Python的Model对象。 Django对于PostgreSQL,MySQL,SQLite和Oracle等数据库都能做到开箱即用。

点击此处了解使用 Django 及其 ORM 进行数据处理的基础知识。

  • Robust Built-in Template System

Based on the inheritance system, Django’s templates allow developers to build entire, dynamic websites out of a very small amount of front-end code. Thanks to the option to replace certain elements of templates with other, context specific elements. Imagine a situation where you know that every page of your site is going to have a header and a footer. Now, you first need to write the code in the site’s base template. And then, you can alter the components between those two things dynamically, from other parts of the application.

  • Simple, Readable URLs

It’s difficult to properly read URLs developed in PHP os ASP. With Django, you can create simple and easy-to-read URLs, which is good for both human beings and search engines. You can create readable URLs with other frameworks too, but none is as easy as Django is for URL construction.

  • 强大的内置模板系统 

基于继承系统,Django 的模板允许开发人员通过非常少量的前端代码构建整个动态网站。这得益于使用其他上下文特定元素替换模板的某些元素的选项。 想象一下,你知道你网站的每个页面都会有一个页眉和一个页脚。 现在,您首先需要在网站的基本模板中编写代码。 然后,您可以从应用程序的其他部分动态地更改这两个内容之间的组件。

  • 简单可读的网址

很难正确阅读在PHP os ASP中开发的URL? 使用 Django,您可以创建简单易读的 URL,这对人和搜索引擎都有好处。 您也可以使用其他框架创建可读 URL,但没有一个与 Django 一样容易进行 URL 构造。

  • Enables Quick and Easy Creation of RSS and Atom feeds

With Django, you can quickly and easily create RSS and Atom feeds by creating a simple Python class.

  • Automatically Creates Tables in Database

If there is a table missing in your database, you can automatically create it by executing the migrate command in Django.

  • Easy Database Migrations

One of the most useful features of Django is database migrations. With Django’s migrations, you can change a database schema in quick time. It’s also easy to track your database schema and its associated changes. Migration names help in managing version control, and a plethora of options are available to merge versions and make modifications.

  • Security

Django is highly secured. The framework comes with default protection against XSS attacks, CSRF attacks, SQL injections, clickjacking, user management, cookies, email header injection, cryptography, directory traversal etc.

快速容易的创建RSS和ATOM feeds

使用 Django,你可以通过创建一个简单的Python类来快速创建 RSS 和 ATOM feeds。

在数据库中自动创建表

如果你的数据库中缺失了某一个表,你可以通过执行 Django 的迁移命令来自动创建它。

容易的数据迁移

 数据迁移是 Django 中最有用的功能之一。通过使用 Django 的迁移方法,你可以在短时间内改变一个数据库模式。同样也容易就能跟踪你的数据库模式和相关的改变。为数据迁移所做的命名能够帮助你进行版本控制,还有很多选项可以用来合并版本和进行修改。

安全性

Django非常安全,该框架默认情况下可以防止 XSS 攻击、CSRF 攻击,SQL 语句注入、点击劫持、用户管理、cookies、邮件标头注入、密码攻击、目录遍历攻击等等。

Django has a very dynamic community, with 80,000 StackOverflow issues and numerous blogs from the developers and power users. Some popular websites that use Django are Bitbucket, Pinterest, Instagram, and The Onion. Django continues to soar in popularity and is likely to remain the most popular choice of Python developers.

Have you used Django for a project before? Do you really think that Django is the best framework for Python developers? As always, your views are vital for all our readers, please share them in the comment box below.

Django有一个非常活跃的社区,有80,000个StackOverflow问题和数不清的博客来自开发人员和高级用户。 有一些流行网站使用Django,包括 Bitbucket, Pinterest, Instagram, 以及 The Onion。 Django的人气不断飙升,可能仍然是Python开发人员最受欢迎的选择。

您之前的项目是否用过Django? 你真的认为Django是Python开发人员最好的框架吗? 一如既往,您的意见对于所有读者都至关重要,请在下面的评论栏中分享您的看法。


返回顶部
顶部