扉頁
-------
#章節預覽 第二版
************
## 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
3. 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
4. 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
5. 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
6. 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
7. 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
8. 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
9. 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
10. 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
11. 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