| ID | English原文 | 中文翻译 | 最近翻译记录 | 状态 | 操作 |
|---|---|---|---|---|---|
| 0#翻译 | Chapter 1: Introduction to Django | 第一章:介绍Django | 翻译 | ||
| 3#翻译 | This book is about Django, a Web development framework that saves you time and makes Web development a joy. | 本书所讲的是Django:一个可以使Web开发工作愉快并且高效的Web开发框架。 | 翻译 | ||
| 4#翻译 | Using Django, you can build and maintain high-quality Web applications with minimal fuss. | 使用Django,使你能够以最小的代价构建和维护高质量的Web应用。 | 翻译 | ||
| 6#翻译 | At its best, Web development is an exciting, creative act; at its worst, it can be a repetitive, frustrating nuisance. | 从好的方面来看,Web 开发激动人心且富于创造性;从另一面来看,它却是份繁琐而令人生厌的工作。 | 翻译 | ||
| 7#翻译 | Django lets you focus on the fun stuff the crux of your Web application while easing the pain of the repetitive bits. | 通过减少重复的代码,Django 使你能够专注于 Web 应用上有 趣的关键性的东西。 | 翻译 | ||
| 8#翻译 | In doing so, it provides high-level abstractions of common Web development patterns, shortcuts for frequent programming tasks, and clear conventions for how to solve problems. | 为了达到这个目标,Django 提供了通用Web开发模式的高度抽象,提供了频繁进行的编程作业的快速解决方法,以及为“如何解决问题”提供了清晰明了的约定。 | 翻译 | ||
| 9#翻译 | At the same time, Django tries to stay out of your way, letting you work outside the scope of the framework as needed. | 同时,Django 尝试留下一些方法,来让你根据需要在framework之外来开发。 | 翻译 | ||
| 11#翻译 | The goal of this book is to make you a Django expert. | 本书的目的是将你培养成Django专家。 | 翻译 | ||
| 12#翻译 | The focus is twofold. | 主要侧重于两方面: | 翻译 | ||
| 13#翻译 | First, we explain, in depth, what Django does and how to build Web applications with it. | 第一,我们深度解释 Django 到底做了哪些工作以及如何用她构建Web应用;第二,我们将会在适当的地方讨论更高级的概念,并解释如何 在自己的项目中高效的使用这些工具。 | 翻译 | ||
| 14#翻译 | Second, we discuss higher-level concepts where appropriate, answering the question How can I apply these tools effectively in my own projects? | 通过阅读此书,你将学会快速开发功能强大网站的技巧,并且你的代码将会十分 清晰,易于维护。 | 翻译 | ||
| 15#翻译 | By reading this book, you'll learn the skills needed to develop powerful Web sites quickly, with code that is clean and easy to maintain. | 本书的代码清晰,易维护,通过学习,可以快速开发功能强大的网站。 | 翻译 | ||
| 17#翻译 | What Is a Web Framework? | 框架是什麼? | 翻译 | ||
| 19#翻译 | Django is a prominent member of a new generation of <emphasis>Web frameworks</emphasis> but what does that term mean, precisely? | Django 在新一代的 <emphasis>Web框架</emphasis> 中非常出色,为什么这么说呢? | 翻译 | ||
| 21#翻译 | To answer that question, let's consider the design of a Web application written in Python <emphasis>without</emphasis> a framework. | 为回答该问题,让我们考虑一下<emphasis>不使用</emphasis>框架设计 Python 网页应用程序的情形。 | 翻译 | ||
| 22#翻译 | Throughout this book, we'll take this approach of showing you basic ways of getting work done <emphasis>without</emphasis> shortcuts, in the hope that you'll recognize why shortcuts are so helpful. | 贯穿整本书,我们多次展示不使用框架实现网站基本功能的方法,让读者认识到框架开发的方便。 | 翻译 | ||
| 23#翻译 | (It's also valuable to know how to get things done without shortcuts because shortcuts aren't always available. | (不使用框架,更多情况是没有合适的框架可用。 | 翻译 | ||
| 24#翻译 | And most importantly, knowing <emphasis>why</emphasis> things work the way they do makes you a better Web developer.) | 最重要的是,理解实现的来龙去脉会使你成为一个优秀的web开发者。) | 翻译 | ||
| 26#翻译 | One of the simplest, most direct ways to build a Python Web app from scratch is to use the Common Gateway Interface (CGI) standard, which was a popular technique circa 1998. | 使用Python开发Web,最简单,原始和直接的办法是使用CGI标准,在1998年这种方式很流行。 | 翻译 | ||
| 27#翻译 | Here's a high-level explanation of how it works: | 现在从应用角度解释它是如何工作: | 翻译 | ||
| 28#翻译 | just create a Python script that outputs HTML, then save the script to a Web server with a .cgi extension and visit the page in your Web browser. | 首先做一个Python脚本,输出HTML代码,然后保存成.cgi扩展名的文件,通过浏览器访问此文件。 | 翻译 | ||
| 29#翻译 | That's it. | 就是这样。 | 翻译 | ||
| 31#翻译 | Here's an example Python CGI script that displays the ten most recently published books from a database. | 如下示例,用Python CGI脚本显示数据库中最新出版的10本书: | 翻译 | ||
| 32#翻译 | Don't worry about syntax details; just get a feel for the basic things it's doing: | 不用关心语法细节;仅仅感觉一下基本实现的方法: | 翻译 | ||
| 35#翻译 | First, to fulfill the requirements of CGI, this code prints a Content-Type line, followed by a blank line. | 首先,用户请求CGI,脚本代码打印Content-Type行,后面跟着换行。 | 翻译 | ||
| 36#翻译 | It prints some introductory HTML, connects to a database and runs a query to retrieve the names of the latest ten books. | 再接下 来是一些HTML的起始标签,然后连接数据库并执行一些查询操作,获取最新的十本书。 | 翻译 | ||
| 37#翻译 | Looping over those books, it generates an HTML list of the titles. | 在遍历这些书的同时,生成一个书名的HTML列表项。 | 翻译 | ||
| 38#翻译 | Finally, it prints the closing HTML and closes the database connection. | 最后,输出HTML的结束标签并且关闭数据库连接。 | 翻译 | ||
| 40#翻译 | With a one-off page like this one, the write-it-from-scratch approach isn't necessarily bad. | 像这样的一次性的动态页面,从头写起的方法并非一定不好。 | 翻译 | ||
| 41#翻译 | For one thing, this code is simple to comprehend even a novice developer can read these 16 lines of Python and understand everything it does, from start to finish. | 其中一点: | 翻译 | ||
| 42#翻译 | There's nothing else to learn, no other code to read. | 这些代码简单易懂,就算是一个初起步的 开发者都能读明白这16行的Python的代码,而且这些代码从头到尾做了什么都能了解得一清二楚。 | 翻译 | ||
| 43#翻译 | It's also simple to deploy: | 不需要学习额外 的背景知识,没有额外的代码需要去了解。 | 翻译 | ||
| 44#翻译 | just save this code in a file that ends with .cgi, upload that file to a Web server, and visit that page with a browser. | 同样,也易于部署这16行代码,只需要将它保存为一个 <literal>latestbooks.cgi</literal> 的 文件,上传到网络服务器上,通过浏览器访问即可。 | 翻译 | ||
| 46#翻译 | But despite its simplicity, this approach has a number of problems and annoyances. | 尽管实现很简单,还是暴露了一些问题和不便的地方。 | 翻译 | ||
| 47#翻译 | Ask yourself these questions: | 问你自己这几个问题: | 翻译 | ||
| 49#翻译 | What happens when multiple parts of your application need to connect to the database? | 应用中有多处需要连接数据库会怎样呢? | 翻译 | ||
| 50#翻译 | Surely that database-connecting code shouldn't need to be duplicated in each individual CGI script. | 每个独立的CGI脚本,不应该重复写数据库连接的代码。 | 翻译 | ||
| 51#翻译 | The pragmatic thing to do would be to refactor it into a shared function. | 比较实用的办法是写一个共享函数,可被多个代码调用。 | 翻译 | ||
| 53#翻译 | Should a developer really have to worry about printing the Content-Type line and remembering to close the database connection? | 一个开发人员 <emphasis>确实</emphasis> 需要去关注如何输出Content-Type以及完成所有操作后去关闭数据 库么? | 翻译 | ||
| 54#翻译 | This sort of boilerplate reduces programmer productivity and introduces opportunities for mistakes. | 此类问题只会降低开发人员的工作效率,增加犯错误的几率。 | 翻译 | ||
| 55#翻译 | These setup- and teardown-related tasks would best be handled by some common infrastructure. | 那些初始化和释放 相关的工作应该交给一些通用的框架来完成。 | 翻译 | ||
| 57#翻译 | What happens when this code is reused in multiple environments, each with a separate database and password? | 如果这样的代码被重用到一个复合的环境中会发生什么? | 翻译 | ||
| 58#翻译 | At this point, some environment-specific configuration becomes essential. | 每个页面都分别对应独立的数据库和密码吗? | 翻译 | ||
| 60#翻译 | What happens when a Web designer who has no experience coding Python wishes to redesign the page? | 如果一个Web设计师,完全没有Python开发经验,但是又需要重新设计页面的话,又将 发生什么呢? | 翻译 | ||
| 61#翻译 | One wrong character could crash the entire application. | 一个字符写错了,可能导致整个应用崩溃。 | 翻译 | ||
| 62#翻译 | Ideally, the logic of the page the retrieval of book titles from the database would be separate from the HTML display of the page, so that a designer could edit the latter without affecting the former. | 理想的情况是,页面显示的逻辑与从数据库中读取书本记录分隔开,这样 Web设计师的重新设计不会影响到之前的业务逻辑。 | 翻译 | ||
| 64#翻译 | These problems are precisely what a Web framework intends to solve. | 以上正是Web框架致力于解决的问题。 | 翻译 | ||
| 65#翻译 | A Web framework provides a programming infrastructure for your applications, so that you can focus on writing clean, maintainable code without having to reinvent the wheel. | Web框架为应用程序提供了一套程序框架, 这样你可以专注于编写清晰、易维护的代码,而无需从头做起。 | 翻译 | ||
| 66#翻译 | In a nutshell, that's what Django does. | 简单来说,这就是Django所能做的。 | 翻译 | ||
| 68#翻译 | The MVC Design Pattern | MVC 设计模式 | 翻译 | ||
| 70#翻译 | Let's dive in with a quick example that demonstrates the difference between the previous approach and a Web framework's approach. | 让我们来研究一个简单的例子,通过该实例,你可以分辨出,通过Web框架来实现的功能与之前的方式有何不同。 | 翻译 | ||
| 71#翻译 | Heres how you might write the previous CGI code using Django. | 下面就是通过使用Django来完成以上功能的例子: | 翻译 | ||
| 72#翻译 | The first thing to note is that that we split it over four Python files (<literal>models.py</literal> , <literal>views.py</literal> , <literal>urls.py</literal> ) and an HTML template (<literal>latest_books.html</literal> ): | 首先,我们分成4个Python的文件,(<literal>models.py</literal> , <literal>views.py</literal> , <literal>urls.py</literal> ) 和html模板文件 (<literal>latest_books.html</literal> ) | 翻译 | ||
| 75#翻译 | Again, don't worry about the particulars of syntax; just get a feel for the overall design. | 然后,不用关心语法细节;只要用心感觉整体的设计。 | 翻译 | ||
| 76#翻译 | The main thing to note here is the <emphasis>separation of concerns</emphasis> : | 这里只关注分割后的几个文件: | 翻译 | ||
| 78#翻译 | The <literal>models.py</literal> file contains a description of the database table, represented by a Python class. | <literal>models.py</literal> 文件主要用一个 Python 类来描述数据表。 | 翻译 | ||
| 79#翻译 | This class is called a <emphasis>model</emphasis> . Using it, you can create, retrieve, update and delete records in your database using simple Python code rather than writing repetitive SQL statements. | 称为 <emphasis>模型(model)</emphasis> 。 运用这个类,你可以通过简单的 Python 的代码来创建、检索、更新、删除 数据库中的记录而无需写一条又一条的SQL语句。 | 翻译 | ||
| 81#翻译 | The <literal>views.py</literal> file contains the business logic for the page. | views.py文件包含了页面的业务逻辑。 | 翻译 | ||
| 82#翻译 | The <literal>latest_books()</literal> function is called a <emphasis>view</emphasis> . | <literal>latest_books()</literal>函数叫做<emphasis>视图</emphasis>。 | 翻译 | ||
| 84#翻译 | The <literal>urls.py</literal> file specifies which view is called for a given URL pattern. | <literal>urls.py</literal> 指出了什么样的 URL 调用什么的视图。 | 翻译 | ||
| 85#翻译 | In this case, the URL <literal>/latest/</literal> will be handled by the <literal>latest_books()</literal> function. | 在这个例子中 <literal>/latest/</literal> URL 将会调用 <literal>latest_books()</literal> 这个函数。 | 翻译 | ||
| 86#翻译 | In other words, if your domain is example.com, any visit to the URL <reference name="http://example.com/latest/" refuri="http://example.com/latest/">http://example.com/latest/</reference> will call the <literal>latest_books()</literal> function. | 换句话说,如果你的域名是example.com,任何人浏览网址<reference name="http://example.com/latest/" refuri="http://example.com/latest/">http://example.com/latest/</reference>将会调用<literal>latest_books()</literal>这个函数。 | 翻译 | ||
| 88#翻译 | The <literal>latest_books.html</literal> file is an HTML template that describes the design of the page. | <literal>latest_books.html</literal> 是 html 模板,它描述了这个页面的设计是如何的。 | 翻译 | ||
| 89#翻译 | It uses a template language with basic logic statements e.g., <literal>{% for book in book_list %}</literal> . | 使用带基本逻辑声明的模板语言,如<literal>{% for book in book_list %}</literal> | 翻译 | ||
| 91#翻译 | Taken together, these pieces loosely follow a pattern called Model-View-Controller (MVC). | 结合起来,这些部分松散遵循的模式称为模型-视图-控制器(MVC)。 | 翻译 | ||
| 92#翻译 | Simply put, MVC is way of developing software so that the code for defining and accessing data (the model) is separate from request-routing logic (the controller), which in turn is separate from the user interface (the view). | 简单的说, MVC 是一种软件开发的方法,它把代码的定义和数据访问的方法(模型)与请求逻辑 (控制器)还有用户接口(视图)分开来。 | 翻译 | ||
| 93#翻译 | (We'll discuss MVC in more depth in Chapter 5.) | 我们将在第5章更深入地讨论MVC。 | 翻译 | ||
| 95#翻译 | A key advantage of such an approach is that components are <emphasis>loosely coupled</emphasis> . Each distinct piece of a Django-powered Web application has a single key purpose and can be changed independently without affecting the other pieces. | 这种设计模式关键的优势在于各种组件都是 <emphasis>松散结合</emphasis> 的。这样,每个由 Django驱动 的Web应用都有着明确的目的,并且可独立更改而不影响到其它的部分。 | 翻译 | ||
| 96#翻译 | For example, a developer can change the URL for a given part of the application without affecting the underlying implementation. | 比如,开发者 更改一个应用程序中的 URL 而不用影响到这个程序底层的实现。 | 翻译 | ||
| 97#翻译 | A designer can change a page's HTML without having to touch the Python code that renders it. | 设计师可以改变 HTML 页面 的样式而不用接触 Python 代码。 | 翻译 | ||
| 98#翻译 | A database administrator can rename a database table and specify the change in a single place, rather than having to search and replace through a dozen files. | 数据库管理员可以重新命名数据表并且只需更改一个地方,无需从一大堆文件中进行查找和替换。 | 翻译 | ||
| 100#翻译 | In this book, each component of MVC gets its own chapter. | 本书中,每个组件都有它自己的一个章节。 | 翻译 | ||
| 101#翻译 | Chapter 3 covers views, Chapter 4 covers templates, and Chapter 5 covers models. | 比如,第三章涵盖了视图,第四章是模板, 而第五章是模型。 | 翻译 | ||
| 103#翻译 | Django's History | Django 历史 | 翻译 | ||
| 105#翻译 | Before we dive into more code, we should take a moment to explain Django's history. | 在我们讨论代码之前我们需要先了解一下 Django 的历史。 | 翻译 | ||
| 106#翻译 | We noted above that we'll be showing you how to do things <emphasis>without</emphasis> shortcuts so that you more fully understand the shortcuts. | 从上面我们注意到:我们将向你展示如何不使用捷径来完成工作,以便能更好的理解捷径的原理 | 翻译 | ||
| 107#翻译 | Similarly, it's useful to understand <emphasis>why</emphasis> Django was created, because knowledge of the history will put into context why Django works the way it does. | 同样,理解Django产生的背景,历史有助于理解Django的实现方式。 | 翻译 | ||
| 109#翻译 | If you've been building Web applications for a while, you're probably familiar with the problems in the CGI example we presented earlier. | 如果你曾编写过网络应用程序。 | 翻译 | ||
| 110#翻译 | The classic Web developer's path goes something like this: | 那么你很有可能熟悉之前我们的 CGI 例子。 | 翻译 | ||
| 112#翻译 | Write a Web application from scratch. | 从头开始编写网络应用程序。 | 翻译 | ||
| 114#翻译 | Write another Web application from scratch. | 从头编写另一个网络应用程序。 | 翻译 | ||
| 116#翻译 | Realize the application from step 1 shares much in common with the application from step 2. | 从第一步中总结(找出其中通用的代码),并运用在第二步中。 | 翻译 | ||
| 118#翻译 | Refactor the code so that application 1 shares code with application 2. | 重构代码使得能在第 2 个程序中使用第 1 个程序中的通用代码。 | 翻译 | ||
| 120#翻译 | Repeat steps 2-4 several times. | 重复 2-4 步骤若干次。 | 翻译 | ||
| 122#翻译 | Realize you've invented a framework. | 意识到你发明了一个框架。 | 翻译 | ||
| 124#翻译 | This is precisely how Django itself was created! | 这正是为什么 Django 建立的原因! | 翻译 | ||
| 126#翻译 | Django grew organically from real-world applications written by a Web development team in Lawrence, Kansas, USA. | Django 是从真实世界的应用中成长起来的,它是由 堪萨斯(Kansas)州 Lawrence 城中的一个 网络开发小组编写的。 | 翻译 | ||
| 127#翻译 | It was born in the fall of 2003, when the Web programmers at the <emphasis>Lawrence Journal-World</emphasis> newspaper, Adrian Holovaty and Simon Willison, began using Python to build applications. | 它诞生于 2003 年秋天,那时 <emphasis>Lawrence Journal-World</emphasis> 报纸的 程序员 Adrian Holovaty 和 Simon Willison 开始用 Python 来编写程序。 | 翻译 | ||
| 129#翻译 | The World Online team, responsible for the production and maintenance of several local news sites, thrived in a development environment dictated by journalism deadlines. | 当时他们的 World Online 小组制作并维护当地的几个新闻站点, 并在以新闻界特有的快节奏开发环境中逐渐发展。 | 翻译 | ||
| 130#翻译 | For the sites including LJWorld.com, Lawrence.com and KUsports.com journalists (and management) demanded that features be added and entire applications be built on an intensely fast schedule, often with only days' or hours notice. | 这些站点包括有 LJWorld.com、Lawrence.com 和 KUsports.com, 记者(或管理层) 要求增加的特征或整个程序都能在计划时间内快速的被建立,这些时间通常只有几天 或几个小时。 | 翻译 | ||
| 131#翻译 | Thus, Simon and Adrian developed a time-saving Web development framework out of necessity it was the only way they could build maintainable applications under the extreme deadlines. | 因此,Adrian 和 Simon 开发了一种节省时间的网络程序开发框架, 这是在截止时间前能完成程序的唯一途径。 | 翻译 | ||
| 133#翻译 | In summer 2005, after having developed this framework to a point where it was efficiently powering most of World Online's sites, the team, which now included Jacob Kaplan-Moss, decided to release the framework as open source software. | 2005 年的夏天,当这个框架开发完成时,它已经用来制作了很多个 World Online 的站点。 | 翻译 | ||
| 134#翻译 | They released it in July 2005 and named it Django, after the jazz guitarist Django Reinhardt. | 当时 World Online 小组中的 Jacob Kaplan-Moss 决定把这个框架发布为一个开源软件。 | 翻译 | ||
| 136#翻译 | Now, several years later, Django is a well-established open source project with tens of thousands of users and contributors spread across the planet. | 从今往后数年,Django是一个有着数以万计的用户和贡献者,在世界广泛传播的完善开源项目。 | 翻译 | ||
| 137#翻译 | Two of the original World Online developers (the Benevolent Dictators for Life, Adrian and Jacob) still provide central guidance for the framework's growth, but its much more of a collaborative team effort. | 原来的World Online的两个开发者(Adrian and Jacob)仍然掌握着Django,但是其发展方向受社区团队的影响更大。 | 翻译 | ||
| 139#翻译 | This history is relevant because it helps explain two key things. | 这些历史都是相关联的,因为她们帮助解释了很重要的两点。 | 翻译 | ||
| 140#翻译 | The first is Django's sweet spot. | 第一,Django最可爱的地方。 | 翻译 | ||
| 141#翻译 | Because Django was born in a news environment, it offers several features (such as its admin site, covered in Chapter 6) that are particularly well suited for content sites sites like Amazon.com, craigslist.org, and washingtonpost.com that offer dynamic, database-driven information. | Django诞生于新闻网站的环境中,因此它提供很多了特性(如第6章会说到的管理后台),非常适合内容类的网站,如Amazon.com, craigslist.org和washingtonpost.com,这些网站提供动态的,数据库驱动的信息。 | 翻译 | ||
| 142#翻译 | Don't let that turn you off, though although Django is particularly good for developing those sorts of sites, that doesn't preclude it from being an effective tool for building any sort of dynamic Web site. | (不要看到这就感到沮丧,尽管Django擅长于动态内容管理系统, 但并不表示Django主要的目的就是用来创建动态内容的网站。 | 翻译 | ||
| 143#翻译 | (There's a difference between being <emphasis>particularly effective</emphasis> at something and being <emphasis>ineffective</emphasis> at other things.) | 某些方面 <emphasis> 特别高效</emphasis> 与其他方面 <emphasis> 不高效</emphasis> 是有区别的, Django在其他方面也同样高效。) | 翻译 | ||
| 145#翻译 | The second matter to note is how Django's origins have shaped the culture of its open source community. | 第二,Django的起源造就了它的开源社区的文化。 | 翻译 | ||
| 146#翻译 | Because Django was extracted from real-world code, rather than being an academic exercise or commercial product, it is acutely focused on solving Web development problems that Django's developers themselves have faced and continue to face. | 因为Django来自于真实世界中的代码,而不是 来自于一个科研项目或者商业产品,她主要集中力量来解决Web开发中遇到的问题,同样 也是Django的开发者经常遇到的问题。 | 翻译 | ||
| 147#翻译 | As a result, Django itself is actively improved on an almost daily basis. | 这样,Django每天在现有的基础上进步。 | 翻译 | ||
| 148#翻译 | The framework's maintainers have a vested interest in making sure Django saves developers time, produces applications that are easy to maintain and performs well under load. | 框架的开发者对于让开发人员节省时间,编写更加容易维护的程序,同时保证程序运行的效率具有极大的兴趣。 | 翻译 | ||
| 149#翻译 | If nothing else, the developers are motivated by their own selfish desires to save themselves time and enjoy their jobs. | 无他,开发者动力来源于自己的目标:节省时间,快乐工作。 | 翻译 | ||
| 150#翻译 | (To put it bluntly, they eat their own dog food.) | (坦率地讲,他们使用了自己公司的产品。) | 翻译 | ||
| 152#翻译 | How to Read This Book | 如何阅读本书 | 翻译 | ||
| 154#翻译 | In writing this book, we tried to strike a balance between readability and reference, with a bias toward readability. | 在编写本书时,我们努力尝试在可读性和参考性间做一个平衡,当然本书会偏向于可 读性。 | 翻译 | ||
| 155#翻译 | Our goal with this book, as stated earlier, is to make you a Django expert, and we believe the best way to teach is through prose and plenty of examples, rather than providing an exhaustive but bland catalog of Django features. | 本书的目标,之前也提过,是要将你培养成一名Django专家,我们相信,最好 的方式就是提供文章和充足的实例,而不是一堆详尽却乏味的关于Django特色的手册。 | 翻译 | ||
| 156#翻译 | (As the saying goes, you can't expect to teach somebody how to speak a language merely by teaching them the alphabet.) | (曾经有人说过,如果仅仅教字母表是无法教会别人说话的。 | 翻译 | ||
| 158#翻译 | With that in mind, we recommend that you read Chapters 1 through 12 in order. | 按照这种思路,我们推荐按顺序阅读第 1-12 章。 | 翻译 | ||
| 159#翻译 | They form the foundation of how to use Django; once you've read them, youll be able to build and deploy Django-powered Web sites. | 这些章节构成了如何使用 Django 的基础;读过之后,你就可以搭建由 Django 支撑的网站了。 | 翻译 | ||
| 160#翻译 | Specifically, Chapters 1 through 7 are the core curriculum, Chapters 8 through 11 cover more advanced Django usage, and Chapter 12 covers deployment. | 1-7章是核心课程,8-11章讲述Django的高级应用,12章讲述部署相关的知识。 | 翻译 | ||
| 161#翻译 | The remaining chapters, 13 through 20, focus on specific Django features and can be read in any order. | 剩下的13-20章,讲述Django特有的特点,可以任意顺序阅读。 | 翻译 | ||
| 163#翻译 | The appendixes are for reference. | 附录部分用作参考资料。 | 翻译 | ||
| 164#翻译 | They, along with the free documentation at <reference name="http://www.djangoproject.com/" refuri="http://www.djangoproject.com/">http://www.djangoproject.com/</reference>, are probably what you'll flip back to occasionally to recall syntax or find quick synopses of what certain parts of Django do. | 要回忆语法或查阅 Django 某部分的功能概要时,你偶尔可能会回来翻翻这些资料以及 <reference name="http://www.djangoproject.com/" refuri="http://www.djangoproject.com/">http://www.djangoproject.com/</reference> 上的免费文档。 | 翻译 | ||
| 166#翻译 | Required Programming Knowledge | 所需编程知识 | 翻译 | ||
| 168#翻译 | Readers of this book should understand the basics of procedural and object-oriented programming: | 本书读者需要理解基本的面向过程和面向对象编程: | 翻译 | ||
| 169#翻译 | control structures (e.g., <literal>if</literal> , <literal>while</literal> , <literal>for</literal> ), data structures (lists, hashes/dictionaries), variables, classes and objects. | 流程控制( <literal>if</literal> , <literal>while</literal> 和 <literal>for</literal> ),数据结构(列表,哈希表/字典),变量,类和对象。 | 翻译 | ||
| 171#翻译 | Experience in Web development is, as you may expect, very helpful, but it's not required to understand this book. | Web开发经验,正如你所想的,也是非常有帮助的,但是对于阅读本书,并不是必须的。 | 翻译 | ||
| 172#翻译 | Throughout the book, we try to promote best practices in Web development for readers who lack this experience. | 通过本书,我们尽量给缺乏经验的开发人员提供在Web开发中最好的实践。 | 翻译 | ||
| 174#翻译 | Required Python Knowledge | Python所需知识 | 翻译 | ||
| 176#翻译 | At its core, Django is simply a collection of libraries written in the Python programming language. | 本质上来说, Django 只不过是用 Python 编写的一组类库。 | 翻译 | ||
| 177#翻译 | To develop a site using Django, you write Python code that uses these libraries. | 用 Django 开发站点就是使用这些类库编写 Python 代码。 | 翻译 | ||
| 178#翻译 | Learning Django, then, is a matter of learning how to program in Python and understanding how the Django libraries work. | 因此,学习 Django 的关键就是学习如何进行 Python 编程并理解 Django 类库的运作方式。 | 翻译 | ||
| 180#翻译 | If you have experience programming in Python, you should have no trouble diving in. | 如果你有Python开发经验,在学习过程中应该不会有任何问题。 | 翻译 | ||
| 181#翻译 | By and large, the Django code doesn't perform a lot of magic (i.e., programming trickery whose implementation is difficult to explain or understand). | 基本上,Django的代码并 没有使用一些黑色魔法(例如代码中的花哨技巧,某个实现解释或者理解起来十分困难)。 | 翻译 | ||
| 182#翻译 | For you, learning Django will be a matter of learning Django's conventions and APIs. | 对你来说,学习Django就是学习她的命名规则和API。 | 翻译 | ||
| 184#翻译 | If you don't have experience programming in Python, you're in for a treat. | 如果你没有使用 Python 编程的经验,你一定会学到很多东西。 | 翻译 | ||
| 185#翻译 | Its easy to learn and a joy to use! | 它是非常易学易用的。 | 翻译 | ||
| 186#翻译 | Although this book doesn't include a full Python tutorial, it highlights Python features and functionality where appropriate, particularly when code doesn't immediately make sense. | 虽然这本书没有包括一个完整的 Python 教程, 但也算是一个恰当的介绍了 Python特征和 功能的集锦。 | 翻译 | ||
| 187#翻译 | Still, we recommend you read the official Python tutorial, available online at <reference name="http://docs.python.org/tut/" refuri="http://docs.python.org/tut/">http://docs.python.org/tut/</reference>. | 当然,我们推荐你读一下官方的 Python 教程,它可 以从 <reference name="http://docs.python.org/tut/" refuri="http://docs.python.org/tut/">http://docs.python.org/tut/</reference> 在线获得。 | 翻译 | ||
| 188#翻译 | We also recommend Mark Pilgrim's free book <emphasis>Dive Into Python</emphasis> , available at <reference name="http://www.diveintopython.org/" refuri="http://www.diveintopython.org/">http://www.diveintopython.org/</reference> and published in print by Apress. | 另外我们也推荐 Mark Pilgrims的 书 <emphasis>Dive Into Python</emphasis> ( <reference name="http://www.diveintopython.org/" refuri="http://www.diveintopython.org/">http://www.diveintopython.org/</reference> ) | 翻译 | ||
| 190#翻译 | Required Django Version | Django版本支持 | 翻译 | ||
| 192#翻译 | This book covers Django 1.1. | 此书内容对Django 1.1兼容。 | 翻译 | ||
| 194#翻译 | Django's developers maintain backwards compatibility within major version numbers. | Django的开发者保证主要版本号向后兼容。 | 翻译 | ||
| 195#翻译 | This commitment means that, if you write an application for Django 1.1, it will still work for 1.2, 1.3, 1.9 and any other version number that starts with 1. | 这意味着,你用Django 1.1写的应用,可以用于1.2,1.3,1.9等所有以1开头的版本 | 翻译 | ||
| 197#翻译 | Once Django hits 2.0, though, your applications might need to be rewritten but version 2.0 is a long way away. | 如果Django到了2.0,你的应用可能不再兼容,需要重写,但是,2.0是很遥远的事情。 | 翻译 | ||
| 198#翻译 | As a point of reference, it took more than three years to release version 1.0. | 对此,可以参考一下1.0的开发周期,整整3年的时间。 | 翻译 | ||
| 199#翻译 | (This is very similar to the compatibility policy taken by the Python language itself: | (这与Python语言的兼容策略非常像: | 翻译 | ||
| 200#翻译 | code that was written for Python 2.0 works on Python 2.6, but not necessarily with Python 3.0.) | 在python 2.0下写的代码可以在python 2.6下运行,但不一定能在python3.0下运行 | 翻译 | ||
| 202#翻译 | Given that this book covers 1.1, it should serve you well for some time. | 所以,此书覆盖1.1版本,可以使用很长时间。 | 翻译 | ||
| 204#翻译 | Getting Help | 获取帮助 | 翻译 | ||
| 206#翻译 | One of the greatest benefits of Django is its kind and helpful user community. | Django的最大的益处是,有一群乐于助人的人在Django社区上。 | 翻译 | ||
| 207#翻译 | For help with any aspect of Django from installation, to application design, to database design, to deployment feel free to ask questions online. | 你可以毫无约束的提各种 问题在上面,如:django的安装,app 设计,db 设计,发布。 | 翻译 | ||
| 209#翻译 | The django-users mailing list is where thousands of Django users hang out to ask and answer questions. | Django邮件列表是很多Django用户提出问题、回答问题的地方。 | 翻译 | ||
| 210#翻译 | Sign up for free at <reference name="http://www.djangoproject.com/r/django-users" refuri="http://www.djangoproject.com/r/django-users">http://www.djangoproject.com/r/django-users</reference>. | 可以通过<reference name="http://www.djangoproject.com/r/django-users" refuri="http://www.djangoproject.com/r/django-users">http://www.djangoproject.com/r/django-users</reference> 来免费注册。 | 翻译 | ||
| 212#翻译 | The Django IRC channel is where Django users hang out to chat and help each other in real time. | 如果Django用户遇到棘手的问题,希望得到及时地回复,可以使用Django IRC channel。 | 翻译 | ||
| 213#翻译 | Join the fun by logging on to #django on the Freenode IRC network. | 在Freenode IRC network加入#django | 翻译 | ||
| 215#翻译 | What's Next | 下一章 | 翻译 | ||
| 217#翻译 | In the <reference name="next chapter" refuri="../chapter02/">next chapter</reference>, we'll get started with Django, covering installation and initial setup. | 在 <reference name="next chapter" refuri="../chapter02/">下一章</reference>,我们将开始使用Django,内容将包括安装和初始化配置。 | 翻译 |