章节预览
1. Getting Started with Django 1.8
- Introduction
- Working with a virtual environment
- Getting ready
- How to do it…
- How it works…
- See also
- Creating a project file structure
- Getting ready
- How to do it…
- How it works…
- See also
- Handling project dependencies with pip - Getting ready - How to do it…
- How it works…
- There's more…
- See also - Making your code compatible with both Python 2.7 and Python 3 - Getting ready - How to do it…
- How it works…
- Including external dependencies in your project - Getting ready - How to do it…
- How it works…
- See also - Configuring settings for development, testing, staging, and production environments - Getting ready - How to do it…
- How it works…
- See also - Defining relative paths in the settings - Getting ready - How to do it…
- How it works…
- See also - Creating and including local settings - Getting ready -How to do it…
-How it works…
- See also - Setting up STATIC_URL dynamically for Subversion users -Getting ready - How to do it…
- How it works…
- See also - Setting up STATIC_URL dynamically for Git users -Getting ready - How to do it…
- How it works…
- See also - Setting UTF-8 as the default encoding for MySQL configuration - Getting ready -How to do it…
-How it works…
- Setting the Subversion ignore property - Getting ready - How to do it…
- How it works…
- See also - Creating the Git ignore file - Getting ready - How to do it…
- How it works…
- See also - Deleting Python-compiled files - Getting ready - How to do it…
- How it works…
- See also - Respecting the import order in Python files - Getting ready - How to do it…
- How it works…
- There's more…
- See also - Creating app configuration - Getting ready - How to do it…
- How it works…
- There is more…
- See also - Defining overwritable app settings - Getting ready - How to do it…
- How it works…
2. Database Structure
Introduction Using model mixins Getting ready How to do it…
How it works…
There's more…
See also Creating a model mixin with URL-related methods Getting ready How to do it…
How it works…
See also Creating a model mixin to handle creation and modification dates Getting ready How to do it…
How it works…
See also Creating a model mixin to take care of meta tags Getting ready How to do it…
How it works…
See also Creating a model mixin to handle generic relations Getting ready How to do it…
How it works…
See also Handling multilingual fields Getting ready How to do it…
How it works…
Using migrations Getting ready How to do it…
How it works…
See also Switching from South migrations to Django migrations Getting ready How to do it…
How it works…
See also Changing a foreign key to the many-to-many field Getting ready How to do it…
How it works…
See also
- Forms and Views Introduction Passing HttpRequest to the form Getting ready How to do it…
How it works…
See also Utilizing the save method of the form Getting ready How to do it…
How it works…
See also Uploading images Getting ready How to do it…
How it works…
There's more See also Creating a form layout with django-crispy-forms Getting ready How to do it…
How it works…
There's more…
See also Downloading authorized files Getting ready How to do it…
How it works…
See also Filtering object lists Getting ready How to do it…
How it works…
See also Managing paginated lists Getting ready How to do it…
How it works…
See also Composing class-based views Getting ready How to do it…
How it works…
There's more…
See also Generating PDF documents Getting ready How to do it…
How it works…
See also Implementing a multilingual search with Haystack Getting ready How to do it…
How it works…
See also - Templates and JavaScript Introduction Arranging the base.html template Getting ready How to do it…
How it works…
See also Including JavaScript settings Getting ready How to do it…
How it works…
See also Using HTML5 data attributes Getting ready How to do it…
How it works…
See also Opening object details in a modal dialog Getting ready How to do it…
How it works…
See also Implementing a continuous scroll Getting ready How to do it…
How it works…
See also Implementing the Like widget Getting ready How to do it…
How it works…
See also Uploading images by Ajax Getting ready How to do it…
How it works…
See also - Custom Template Filters and Tags Introduction Following conventions for your own template filters and tags How to do it... Creating a template filter to show how many days have passed since a post was published Getting ready How to do it... How it works... There's more... See also Creating a template filter to extract the first media object Getting ready How to do it... How it works... There's more... See also Creating a template filter to humanize URLs Getting ready How to do it... How it works... See also Creating a template tag to include a template if it exists Getting ready How to do it... How it works... There's more... See also Creating a template tag to load a QuerySet in a template Getting ready How to do it... How it works... See also Creating a template tag to parse content as a template Getting ready How to do it... How it works... See also Creating a template tag to modify request query parameters Getting ready How to do it... How it works... See also
- Model Administration Introduction Customizing columns on the change list page Getting ready How to do it... How it works... There's more... See also Creating admin actions Getting ready How to do it... How it works... See also Developing change list filters Getting ready How to do it... How it works... See also Customizing default admin settings Getting ready How to do it... How it works... There's more... See also Inserting a map into a change form Getting ready How to do it... How it works... See also
- Django CMS Introduction Creating templates for Django CMS Getting ready How to do it... How it works... See also Structuring the page menu Getting ready How to do it... How it works... See also Converting an app to a CMS app Getting ready How to do it... How it works... See also Attaching your own navigation Getting ready How to do it... How it works... See also Writing your own CMS plugin Getting ready How to do it... How it works... See also Adding new fields to the CMS page Getting ready How to do it... How it works... See also
- Hierarchical Structures Introduction Creating hierarchical categories Getting ready How to do it... How it works... See also Creating a category administration interface with django-mptt-admin Getting ready How to do it... How it works... See also Creating a category administration interface with django-mptt-tree-editor Getting ready How to do it... How it works... See also Rendering categories in a template Getting ready How to do it... How it works... There's more... See also Using a single selection field to choose a category in forms Getting ready How to do it... How it works... See also Using a checkbox list to choose multiple categories in forms Getting ready How to do it... How it works... See also
- Data Import and Export Introduction Importing data from a local CSV file Getting ready How to do it... How it works... There's more... See also Importing data from a local Excel file Getting ready How to do it... How it works... There's more... See also Importing data from an external JSON file Getting ready How to do it... How it works... See also Importing data from an external XML file Getting ready How to do it... How it works... There's more... See also Creating filterable RSS feeds Getting ready How to do it... How it works... See also Using Tastypie to create API Getting ready How to do it... How it works... See also Using Django REST framework to create API Getting ready How to do it... How it works... See also
- Bells and Whistles Introduction Using the Django shell Getting ready How to do it... How it works... See also Using database query expressions Getting ready How to do it... How it works... See also Monkey-patching the slugify() function for better internationalization support Getting ready How to do it... How it works... There's more... See also Toggling the Debug Toolbar Getting ready How to do it... How it works... See also Using ThreadLocalMiddleware Getting ready How to do it... How it works... See also Caching the method return value Getting ready How to do it... How it works... See also Using Memcached to cache Django views Getting ready How to do it... How it works... See also Using signals to notify administrators about new entries Getting ready How to do it... How it works... See also Checking for missing settings Getting ready How to do it... How it works... See also
- Testing and Deployment Introduction Testing pages with Selenium Getting ready How to do it... How it works... See also Testing views with mock Getting ready How to do it... How it works... See also Testing API created using Django REST framework Getting ready How to do it... How it works... See also Releasing a reusable Django app Getting ready How to do it... How it works... See also Getting detailed error reporting via e-mail Getting ready How to do it... How it works... See also Deploying on Apache with mod_wsgi Getting ready How to do it... How it works... There's more... See also Setting up cron jobs for regular tasks Getting ready How to do it... How it works... See also Creating and using the Fabric deployment script Getting ready How to do it... How it works... There's more... See also
第一章, 从 Django1.6 开始
指导你通过必要的基本配置以新建任意 Django 项目。本章覆盖内容有,虚拟环境,会话控制,以及项目设置。
- 使用虚拟环境
- 创建一个项目文件结构
- 用 pip 处理项目依赖
- 在项目中包括外部的依赖
- 在 settings 中定义相对路径
- 为 Subersion 用户动态地配置 STATIC_URL
- 为 Git 用户动态地配置 STATIC_URL
- 创建并包括本地设置
- 把 UTF-8 设置为 MySQL 配置的默认编码格式
- 设置 Subversion 的忽略特性
- 创建 Git 的忽略文件
- 删除 Python 编译文件
- Python 文件中的导入顺序
- 定义可重写的 app 设置
第二章, 数据库结构
教会你如何写可重复使用的代码片段并用在模型中。当你创建一个新的 app 时,要做的第一件就是定义模型。你也告知如何使用 Sou
- 使用模型 mixin
- 使用相对 URL 方法创建一个模型 mixin
- 创建一个模型 mixin 以处理日期的创建和修改
- 创建一个模型 mixin 以处理 meta 标签
- 创建一个模型 mixin 以处理通用关系
- 处理多语言字段
- 使用 South 迁移 (译者注:Django1.7 中已经有了自己迁移模块,故内容将略去)
- 使用 South 将一个外键改变为多対多字段
第三章, 表单和视图
向你演示使用一些模式为数据创建视图和表单
- 传递 HttpRequest 到表单
- 利用表单的 save 方法
- 上传图片
- 使用 django-crispy-forms 生成表单布局
- 过滤对象列表
- 管理分页列表
- 编写类视图
- 生成 PDF 文档
第四章, 模板和 JavaScript
向你演示把模板和 JavaScript 放在一起使用的实际例子。我们把模板和 JavaScript 放在一起是因为,总是通过渲染模板将内容展现给用户,在现代的网站中,JavaScript 对于更丰富的用户体验也是必要的。
- 整理 base.html 模板
- 包含 JavaScript 设置
- 使用 HTML5 数据属性
- 在弹窗中显示对象细节
- 实现不间断滚动
- 实现 Like 部件
- 使用 Ajax 上传图片
第五章, 自定义模板过滤器和标签
本章向你演示如如何创建并使用模板过滤器和标签,因为,Django 的模板系统包含内容极广,因此可以有更多的东西对不同的应用场景来添加。
- 遵循模板过滤器和标签的约定
- 创建一个模板过滤器以显示经过的天数
- 创建一个模板过滤器提取第一个媒体对象
- 创建一个模板过滤器使 URL 可读
- 创建一个模板标签在模板中载入一个 QuerySet
- 创建一个模板标签为模板解析内容
- 创建一个模板标签修改 request 查询参数
第六章, 模型管理
本章,将指导你通过扩展默认管理带上自定义的功能,就和 Django 框架自带的预构建的模型管理一样好用。
- 定制换表页面中列
- 新建 admin 的行为
- 开发换表的过滤器
- 为外部的应用交换管理上的设置
- 将地图插入到交换表单
第七章, Django CMS
- 为 Django CMS 创建模板
- 组织页面按钮
- 将一个应用转换为 CMS 应用
- 添加自己的导航
- 编写自定义的 CMS 插件
- 对 CMS 页面添加新的字段
第八章, 层级结构
- 生成层级目录
- 利用 django-mptt-admin 新建一个目录的管理接口
- 使用 django-mptt-tree-editor 创建一个目录的管理接口
- 在模板中渲染目录
- 在表单中利用一个单选字段来选择一个目录
- 于表单之中使用一个多选框列表来选择多个字段
第九章, 数据的导入和导出
- 从本地的 CSV 文件中导入数据
- 由本地 Excel 文件导入数据
- 打外部 JSON 文件导入数据
- 自外部 XML 文件导入数据
- 创建可过滤的 RSS 订阅
- 使用 Tastypie 为第三方提供数据
第十章, 附加功能
- 使用 Django 的命令行
- Using the Django shell
- The monkey patching slugification function
- The monkey patching model administration
- Toggling Debug Toolbar
- Using ThreadLocalMiddleware
- Caching the method value
- Getting detailed error reporting via e-mail
- Deploying on Apache with mod_wsgi
- Creating and using the Fabric deployment script
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论