Home Page Icon
Home Page
Table of Contents for
3. Other Django Features
Close
3. Other Django Features
by Jacob Kaplan-Moss, Adrian Holovaty
The Definitive Guide to Django: Web Development Done Right, Second Edition
Copyright
About the Authors
About the Technical Reviewer
Acknowledgments
Preface
Introduction
1. Getting Started
1. Introduction to Django
1.1. What Is a Web Framework?
1.2. The MVC Design Pattern
1.3. Django's History
1.4. How to Read This Book
1.4.1. Required Programming Knowledge
1.4.2. Required Python Knowledge
1.4.3. Required Django Version
1.5. Getting Help
1.6. What's Next?
2. Getting Started
2.1. Installing Python
2.1.1. Python Versions
2.1.2. Installation
2.2. Installing Django
2.2.1. Installing an Official Release
2.2.2. Installing the Trunk Version
2.3. Testing the Django Installation
2.4. Setting Up a Database
2.4.1. Using Django with PostgreSQL
2.4.2. Using Django with SQLite 3
2.4.3. Using Django with MySQL
2.4.4. Using Django with Oracle
2.4.5. Using Django Without a Database
2.5. Starting a Project
2.5.1. Running the Development Server
2.6. What's Next?
3. Views and URLconfs
3.1. Your First Django-Powered Page: Hello World
3.1.1. Your First View
3.1.2. Your First URLconf
3.1.3. A Quick Note About 404 Errors
3.1.4. A Quick Note About the Site Root
3.2. How Django Processes a Request
3.3. Your Second View: Dynamic Content
3.4. URLconfs and Loose Coupling
3.5. Your Third View: Dynamic URLs
3.6. Django's Pretty Error Pages
3.7. What's Next?
4. Templates
4.1. Template-System Basics
4.2. Using the Template System
4.2.1. Creating Template Objects
4.2.2. Rendering a Template
4.2.3. Multiple Contexts, Same Template
4.2.4. Context Variable Lookup
4.2.4.1. Method-Call Behavior
4.2.4.2. How Invalid Variables Are Handled
4.2.5. Playing with Context Objects
4.3. Basic Template Tags and Filters
4.3.1. Tags
4.3.1.1. if/else
4.3.1.2. for
4.3.1.3. ifequal/ifnotequal
4.3.1.4. Comments
4.3.2. Filters
4.4. Philosophies and Limitations
4.5. Using Templates in Views
4.6. Template Loading
4.6.1. render_to_response()
4.6.2. The locals() Trick
4.6.3. Subdirectories in get_template()
4.6.4. The include Template Tag
4.7. Template Inheritance
4.8. What's Next?
5. Models
5.1. The "Dumb" Way to Do Database Queries in Views
5.2. The MTV (or MVC) Development Pattern
5.3. Configuring the Database
5.4. Your First App
5.5. Defining Models in Python
5.6. Your First Model
5.7. Installing the Model
5.8. Basic Data Access
5.9. Adding Model String Representations
5.10. Inserting and Updating Data
5.11. Selecting Objects
5.11.1. Filtering Data
5.11.2. Retrieving Single Objects
5.11.3. Ordering Data
5.11.4. Chaining Lookups
5.11.5. Slicing Data
5.11.6. Updating Multiple Objects in One Statement
5.12. Deleting Objects
5.13. What's Next?
6. The Django Admin Site
6.1. The django.contrib Packages
6.2. Activating the Admin Interface
6.3. Using the Admin Site
6.4. Adding Your Models to the Admin Site
6.5. How the Admin Site Works
6.6. Making Fields Optional
6.6.1. Making Date and Numeric Fields Optional
6.7. Customizing Field Labels
6.8. Custom ModelAdmin Classes
6.8.1. Customizing Change Lists
6.8.2. Customizing Edit Forms
6.9. Users, Groups, and Permissions
6.10. When and Why to Use the Admin Interface—And When Not To
6.11. What's Next?
7. Forms
7.1. Getting Data from the Request Object
7.1.1. Information About the URL
7.1.2. Other Information About the Request
7.1.3. Information About Submitted Data
7.2. A Simple Form-Handling Example
7.3. Improving Our Simple Form-Handling Example
7.4. Simple Validation
7.5. Making a Contact Form
7.6. Your First Form Class
7.6.1. Tying Form Objects into Views
7.6.2. Changing How Fields Are Rendered
7.6.3. Setting a Maximum Length
7.6.4. Setting Initial Values
7.6.5. Adding Custom Validation Rules
7.6.6. Specifying Labels
7.6.7. Customizing Form Design
7.7. What's Next?
2. Advanced Usage
8. Advanced Views and URLconfs
8.1. URLconf Tricks
8.1.1. Streamlining Function Imports
8.1.2. Using Multiple View Prefixes
8.1.3. Special-Casing URLs in Debug Mode
8.1.4. Using Named Groups
8.1.5. Understanding the Matching/Grouping Algorithm
8.1.6. Passing Extra Options to View Functions
8.1.6.1. Faking Captured URLconf Values
8.1.6.2. Making a View Generic
8.1.6.3. Giving a View Configuration Options
8.1.6.4. Understanding Precedence of Captured Values vs. Extra Options
8.1.7. Using Default View Arguments
8.1.8. Special-Casing Views
8.1.9. Capturing Text in URLs
8.1.10. Determining What the URLconf Searches Against
8.1.11. Higher-Level Abstractions of View Functions
8.1.12. Wrapping View Functions
8.2. Including Other URLconfs
8.2.1. How Captured Parameters Work with include()
8.2.2. How Extra URLconf Options Work with include()
8.3. What's Next?
9. Advanced Templates
9.1. Template Language Review
9.2. RequestContext and Context Processors
9.2.1. django.core.context_processors.auth
9.2.2. django.core.context_processors.debug
9.2.3. django.core.context_processors.i18n
9.2.4. django.core.context_processors.request
9.2.5. Guidelines for Writing Your Own Context Processors
9.3. Automatic HTML Escaping
9.3.1. How to Turn It Off
9.3.1.1. For Individual Variables
9.3.1.2. For Template Blocks
9.3.2. Notes
9.3.3. Automatic Escaping of String Literals in Filter Arguments
9.4. Inside Template Loading
9.5. Extending the Template System
9.5.1. Creating a Template Library
9.5.2. Writing Custom Template Filters
9.5.3. Writing Custom Template Tags
9.5.4. Writing the Compilation Function
9.5.5. Writing the Template Node
9.5.6. Registering the Tag
9.5.7. Setting a Variable in the Context
9.5.8. Parsing Until Another Template Tag
9.5.9. Parsing Until Another Template Tag and Saving Contents
9.5.10. Shortcut for Simple Tags
9.5.11. Inclusion Tags
9.6. Writing Custom Template Loaders
9.7. Configuring the Template System in Standalone Mode
9.8. What's Next?
10. Advanced Models
10.1. Related Objects
10.1.1. Accessing Foreign Key Values
10.1.2. Accessing Many-to-Many Values
10.2. Making Changes to a Database Schema
10.2.1. Adding Fields
10.2.2. Removing Fields
10.2.3. Removing Many-to-Many Fields
10.2.4. Removing Models
10.3. Managers
10.3.1. Adding Extra Manager Methods
10.3.2. Modifying Initial Manager QuerySets
10.4. Model Methods
10.5. Executing Raw SQL Queries
10.6. What's Next?
11. Generic Views
11.1. Using Generic Views
11.2. Generic Views of Objects
11.3. Extending Generic Views
11.3.1. Making "Friendly" Template Contexts
11.3.2. Adding Extra Context
11.3.3. Viewing Subsets of Objects
11.3.4. Complex Filtering with Wrapper Functions
11.3.5. Performing Extra Work
11.4. What's Next?
12. Deploying Django
12.1. Preparing Your Codebase for Production
12.1.1. Turning Off Debug Mode
12.1.2. Turning Off Template Debug Mode
12.1.3. Implementing a 404 Template
12.1.4. Implementing a 500 Template
12.1.5. Setting Up Error Alerts
12.1.6. Setting Up Broken Link Alerts
12.2. Using Different Settings for Production
12.3. DJANGO_SETTINGS_MODULE
12.4. Using Django with Apache and mod_python
12.4.1. Basic Configuration
12.4.2. Running Multiple Django Installations on the Same Apache Instance
12.4.3. Running a Development Server with mod_python
12.4.4. Serving Django and Media Files from the Same Apache Instance
12.4.5. Error Handling
12.4.6. Handling a Segmentation Fault
12.4.7. An Alternative: mod_wsgi
12.5. Using Django with FastCGI
12.5.1. FastCGI Overview
12.5.2. Running Your FastCGI Server
12.5.2.1. Stopping the FastCGI Daemon
12.5.3. Using Django with Apache and FastCGI
12.5.3.1. Specifying the Location of the FastCGI Server
12.5.3.2. Using mod_rewrite to Point URLs at FastCGI
12.5.4. FastCGI and lighttpd
12.5.4.1. Running Multiple Django Sites on One lighttpd Instance
12.5.5. Running Django on a Shared-Hosting Provider with Apache
12.5.5.1. Restarting the Spawned Server
12.6. Scaling
12.6.1. Running on a Single Server
12.6.2. Separating Out the Database Server
12.6.3. Running a Separate Media Server
12.6.4. Implementing Load Balancing and Redundancy
12.6.5. Going Big
12.7. Performance Tuning
12.7.1. There's No Such Thing As Too Much RAM
12.7.2. Turn Off Keep-Alive
12.7.3. Use Memcached
12.7.4. Use Memcached Often
12.7.5. Join the Conversation
12.8. What's Next?
3. Other Django Features
13. Generating Non-HTML Content
13.1. The Basics: Views and MIME Types
13.2. Producing CSV
13.3. Generating PDFs
13.3.1. Installing ReportLab
13.3.2. Writing Your View
13.3.3. Complex PDFs
13.4. Other Possibilities
13.5. The Syndication-Feed Framework
13.5.1. Initialization
13.5.2. A Simple Feed
13.5.3. A More Complex Feed
13.5.4. Specifying the Type of Feed
13.5.5. Enclosures
13.5.6. Language
13.5.7. URLs
13.5.8. Publishing Atom and RSS Feeds in Tandem
13.6. The Sitemap Framework
13.6.1. Installation
13.6.2. Initialization
13.6.3. Sitemap Classes
13.6.4. Shortcuts
13.6.4.1. FlatPageSitemap
13.6.4.2. GenericSitemap
13.6.5. Creating a Sitemap Index
13.6.6. Pinging Google
13.7. What's Next?
14. Sessions, Users, and Registration
14.1. Cookies
14.1.1. Getting and Setting Cookies
14.1.2. The Mixed Blessing of Cookies
14.2. Django's Session Framework
14.2.1. Enabling Sessions
14.2.2. Using Sessions in Views
14.2.3. Setting Test Cookies
14.2.4. Using Sessions Outside of Views
14.2.5. When Sessions Are Saved
14.2.6. Browser-Length Sessions vs. Persistent Sessions
14.2.7. Other Session Settings
14.3. Users and Authentication
14.3.1. Enabling Authentication Support
14.3.2. Using Users
14.3.3. Logging In and Out
14.3.4. Limiting Access to Logged-in Users
14.3.5. Limiting Access to Users Who Pass a Test
14.3.6. Managing Users, Permissions, and Groups
14.3.6.1. Creating Users
14.3.6.2. Changing Passwords
14.3.6.3. Handling Registration
14.3.7. Using Authentication Data in Templates
14.4. Permissions, Groups, and Messages
14.4.1. Permissions
14.4.2. Groups
14.4.3. Messages
14.5. What's Next?
15. Caching
15.1. Setting Up the Cache
15.1.1. Memcached
15.1.2. Database Caching
15.1.3. Filesystem Caching
15.1.4. Local-Memory Caching
15.1.5. Dummy Caching (for Development)
15.1.6. Using a Custom Cache Back-End
15.1.7. CACHE_BACKEND Arguments
15.2. The Per-Site Cache
15.3. The Per-View Cache
15.3.1. Specifying Per-View Cache in the URLconf
15.4. Template Fragment Caching
15.5. The Low-Level Cache API
15.6. Upstream Caches
15.7. Using Vary Headers
15.8. Controlling Cache: Using Other Headers
15.9. Other Optimizations
15.10. Order of MIDDLEWARE_CLASSES
15.11. What's Next?
16. django.contrib
16.1. The Django Standard Library
16.2. Sites
16.2.1. Scenario 1: Reusing Data on Multiple Sites
16.2.2. Scenario 2: Storing Your Site Name/Domain in One Place
16.2.3. How to Use the Sites Framework
16.2.4. The Sites Framework's Capabilities
16.2.4.1. Reusing Data on Multiple Sites
16.2.4.2. Associating Content with a Single Site
16.2.4.3. Hooking into the Current Site from Views
16.2.4.4. Getting the Current Domain for Display
16.2.5. CurrentSiteManager
16.2.6. How Django Uses the Sites Framework
16.3. Flatpages
16.3.1. Using Flatpages
16.3.2. Adding, Changing, and Deleting Flatpages
16.3.2.1. Via the Admin Interface
16.3.2.2. Via the Python API
16.3.3. Using Flatpage Templates
16.4. Redirects
16.4.1. Using the Redirects Framework
16.4.2. Adding, Changing, and Deleting Redirects
16.4.2.1. Via the Admin Interface
16.4.2.2. Via the Python API
16.5. CSRF Protection
16.5.1. A Simple CSRF Example
16.5.2. A More Complex CSRF Example
16.5.3. Preventing CSRF
16.5.3.1. Using the CSRF Middleware
16.5.3.2. Limitations of the CSRF Middleware
16.6. Humanizing Data
16.6.1. apnumber
16.6.2. intcomma
16.6.3. intword
16.6.4. ordinal
16.7. Markup Filters
16.8. What's Next?
17. Middleware
17.1. What's Middleware?
17.2. Middleware Installation
17.3. Middleware Methods
17.3.1. Initializer: __init__(self)
17.3.2. Request Preprocessor: process_request(self, request)
17.3.3. View Preprocessor: process_view(self, request, view, args, kwargs)
17.3.4. Response Postprocessor: process_response(self, request, response)
17.3.5. Exception Postprocessor: process_exception(self, request, exception)
17.4. Built-in Middleware
17.4.1. Authentication Support Middleware
17.4.2. "Common" Middleware
17.4.3. Compression Middleware
17.4.4. Conditional GET Middleware
17.4.5. Reverse Proxy Support (X-Forwarded-For Middleware)
17.4.6. Session Support Middleware
17.4.7. Sitewide Cache Middleware
17.4.8. Transaction Middleware
17.5. What's Next?
18. Integrating with Legacy Databases and Applications
18.1. Integrating with a Legacy Database
18.1.1. Using inspectdb
18.1.2. Cleaning Up Generated Models
18.2. Integrating with an Authentication System
18.2.1. Specifying Authentication Back-Ends
18.2.2. Writing an Authentication Back-End
18.3. Integrating with Legacy Web Applications
18.4. What's Next?
19. Internationalization
19.1. How to Specify Translation Strings
19.1.1. In Python Code
19.1.1.1. Standard Translation
19.1.1.2. Marking Strings As No-Op
19.1.1.3. Lazy Translation
19.1.1.4. Pluralization
19.1.2. In Template Code
19.1.3. Working with Lazy Translation Objects
19.1.3.1. Joining Strings: string_concat()
19.1.3.2. The allow_lazy() Decorator
19.2. How to Create Language Files
19.2.1. Message Files
19.2.2. Compiling Message Files
19.3. How Django Discovers Language Preference
19.4. Using Translations in Your Own Projects
19.5. The set_language Redirect View
19.6. Translations and JavaScript
19.6.1. The javascript_catalog View
19.6.2. Using the JavaScript Translation Catalog
19.6.3. Creating JavaScript Translation Catalogs
19.7. Notes for Users Familiar with gettext
19.8. gettext on Windows
19.9. What's Next?
20. Security
20.1. The Theme of Web Security
20.2. SQL Injection
20.2.1. The Solution
20.3. Cross-Site Scripting (XSS)
20.3.1. The Solution
20.4. Cross-Site Request Forgery
20.5. Session Forging/Hijacking
20.5.1. The Solution
20.6. E-mail Header Injection
20.6.1. The Solution
20.7. Directory Traversal
20.7.1. The Solution
20.8. Exposed Error Messages
20.8.1. The Solution
20.9. A Final Word on Security
20.10. What's Next?
4. Appendixes
A. Model Definition Reference
A.1. Fields
A.1.1. AutoField
A.1.2. BooleanField
A.1.3. CharField
A.1.4. CommaSeparatedIntegerField
A.1.5. DateField
A.1.6. DateTimeField
A.1.7. DecimalField
A.1.8. EmailField
A.1.9. FileField
A.1.10. FilePathField
A.1.11. FloatField
A.1.12. ImageField
A.1.13. IntegerField
A.1.14. IPAddressField
A.1.15. NullBooleanField
A.1.16. PositiveIntegerField
A.1.17. PositiveSmallIntegerField
A.1.18. SlugField
A.1.19. SmallIntegerField
A.1.20. TextField
A.1.21. TimeField
A.1.22. URLField
A.1.23. XMLField
A.2. Universal Field Options
A.2.1. null
A.2.2. blank
A.2.3. choices
A.2.4. db_column
A.2.5. db_index
A.2.6. db_tablespace
A.2.7. default
A.2.8. editable
A.2.9. help_text
A.2.10. primary_key
A.2.11. unique
A.2.12. unique_for_date
A.2.13. unique_for_month
A.2.14. unique_for_year
A.2.15. verbose_name
A.3. Relationships
A.3.1. ForeignKey
A.3.2. ManyToManyField
A.3.3. OneToOneField
A.4. Model Metadata Options
A.4.1. abstract
A.4.2. db_table
A.4.2.1. Table names
A.4.3. db_tablespace
A.4.4. get_latest_by
A.4.5. managed
A.4.6. ordering
A.4.7. proxy
A.4.8. unique_together
A.4.9. verbose_name
A.4.10. verbose_name_plural
B. Database API Reference
B.1. Creating Objects
B.1.1. What Happens When You Save?
B.1.2. Autoincrementing Primary Keys
B.2. Saving Changes to Objects
B.3. Retrieving Objects
B.4. Caching and QuerySets
B.5. Filtering Objects
B.5.1. Chaining Filters
B.5.2. Limiting QuerySets
B.5.3. Query Methods That Return New QuerySets
B.5.3.1. filter(**lookup)
B.5.3.2. exclude(**lookup)
B.5.3.3. order_by(*fields)
B.5.3.4. distinct()
B.5.3.5. values(*fields)
B.5.3.6. dates(field, kind, order)
B.5.3.7. select_related()
B.5.4. QuerySet Methods That Do Not Return QuerySets
B.5.4.1. get(**lookup)
B.5.4.2. create(**kwargs)
B.5.4.3. get_or_create(**kwargs)
B.5.4.4. count()
B.5.4.5. in_bulk(id_list)
B.5.4.6. latest(field_name=None)
B.6. Field Lookups
B.6.1. exact
B.6.2. iexact
B.6.3. contains
B.6.4. icontains
B.6.5. gt, gte, lt, and lte
B.6.6. in
B.6.7. startswith
B.6.8. istartswith
B.6.9. endswith and iendswith
B.6.10. range
B.6.11. year, month, and day
B.6.12. isnull
B.6.13. search
B.6.14. The pk Lookup Shortcut
B.7. Complex Lookups with Q Objects
B.8. Related Objects
B.8.1. Lookups That Span Relationships
B.8.2. Foreign-Key Relationships
B.8.3. "Reverse" Foreign-Key Relationships
B.8.4. Many-to-Many Relationships
B.8.5. Queries over Related Objects
B.9. Deleting Objects
B.10. Shortcuts
B.10.1. get_object_or_404()
B.10.2. get_list_or_404()
B.11. Falling Back to Raw SQL
C. Generic View Reference
C.1. Common Arguments to Generic Views
C.2. "Simple" Generic Views
C.2.1. Rendering a Template
C.2.1.1. Example
C.2.1.2. Required Arguments
C.2.2. Redirecting to Another URL
C.2.2.1. Example
C.2.2.2. Required Arguments
C.3. List/Detail Generic Views
C.3.1. Lists of Objects
C.3.1.1. Example
C.3.1.2. Required Arguments
C.3.1.3. Optional Arguments
C.3.1.4. Template Name
C.3.1.5. Template Context
C.3.2. Detail Views
C.3.2.1. Example
C.3.2.2. Required Arguments
C.3.2.3. Optional Arguments
C.3.2.4. Template Name
C.3.2.5. Template Context
C.4. Date-Based Generic Views
C.4.1. Archive Index
C.4.1.1. Example
C.4.1.2. Required Arguments
C.4.1.3. Optional Arguments
C.4.1.4. Template Name
C.4.1.5. Template Context
C.4.2. Year Archives
C.4.2.1. Example
C.4.2.2. Required Arguments
C.4.2.3. Optional Arguments
C.4.2.4. Template Name
C.4.2.5. Template Context
C.4.3. Month Archives
C.4.3.1. Example
C.4.3.2. Required Arguments
C.4.3.3. Optional Arguments
C.4.3.4. Template Name
C.4.3.5. Template Context
C.4.4. Week Archives
C.4.4.1. Example
C.4.4.2. Required Arguments
C.4.4.3. Optional Arguments
C.4.4.4. Template Name
C.4.4.5. Template Context
C.4.5. Day Archives
C.4.5.1. Example
C.4.5.2. Required Arguments
C.4.5.3. Optional Arguments
C.4.5.4. Template Name
C.4.5.5. Template Context
C.4.6. Archive for Today
C.4.6.1. Example
C.4.7. Date-Based Detail Pages
C.4.7.1. Example
C.4.7.2. Required Arguments
C.4.7.3. Optional Arguments
C.4.7.4. Template Name
C.4.7.5. Template Context
D. Settings
D.1. The Basics of Settings Files
D.1.1. Default Settings
D.1.2. Seeing Which Settings You've Changed
D.1.3. Using Settings in Python Code
D.1.4. Altering Settings at Runtime
D.1.5. Security
D.1.6. Creating Your Own Settings
D.2. Designating the Settings: DJANGO_SETTINGS_MODULE
D.2.1. The django-admin.py Utility
D.2.2. On the Server (mod_python)
D.3. Using Settings Without Setting DJANGO_SETTINGS_MODULE
D.3.1. Custom Default Settings
D.3.2. Either configure() or DJANGO_SETTINGS_MODULE Is Required
D.4. Available Settings
D.4.1. ABSOLUTE_URL_OVERRIDES
D.4.2. ADMIN_MEDIA_PREFIX
D.4.3. ADMINS
D.4.4. ALLOWED_INCLUDE_ROOTS
D.4.5. APPEND_SLASH
D.4.6. CACHE_BACKEND
D.4.7. CACHE_MIDDLEWARE_KEY_PREFIX
D.4.8. DATABASE_ENGINE
D.4.9. DATABASE_HOST
D.4.10. DATABASE_NAME
D.4.11. DATABASE_OPTIONS
D.4.12. DATABASE_PASSWORD
D.4.13. DATABASE_PORT
D.4.14. DATABASE_USER
D.4.15. DATE_FORMAT
D.4.16. DATETIME_FORMAT
D.4.17. DEBUG
D.4.18. DEFAULT_CHARSET
D.4.19. DEFAULT_CONTENT_TYPE
D.4.20. DEFAULT_FROM_EMAIL
D.4.21. DISALLOWED_USER_AGENTS
D.4.22. EMAIL_HOST
D.4.23. EMAIL_HOST_PASSWORD
D.4.24. EMAIL_HOST_USER
D.4.25. EMAIL_PORT
D.4.26. EMAIL_SUBJECT_PREFIX
D.4.27. FIXTURE_DIRS
D.4.28. IGNORABLE_404_ENDS
D.4.29. IGNORABLE_404_STARTS
D.4.30. INSTALLED_APPS
D.4.31. LANGUAGE_CODE
D.4.32. LANGUAGES
D.4.33. MANAGERS
D.4.34. MEDIA_ROOT
D.4.35. MEDIA_URL
D.4.36. MIDDLEWARE_CLASSES
D.4.37. MONTH_DAY_FORMAT
D.4.38. PREPEND_WWW
D.4.39. ROOT_URLCONF
D.4.40. SECRET_KEY
D.4.41. SEND_BROKEN_LINK_EMAILS
D.4.42. SERIALIZATION_MODULES
D.4.43. SERVER_EMAIL
D.4.44. SESSION_COOKIE_AGE
D.4.45. SESSION_COOKIE_DOMAIN
D.4.46. SESSION_COOKIE_NAME
D.4.47. SESSION_COOKIE_SECURE
D.4.48. SESSION_EXPIRE_AT_BROWSER_CLOSE
D.4.49. SESSION_SAVE_EVERY_REQUEST
D.4.50. SITE_ID
D.4.51. TEMPLATE_CONTEXT_PROCESSORS
D.4.52. TEMPLATE_DEBUG
D.4.53. TEMPLATE_DIRS
D.4.54. TEMPLATE_LOADERS
D.4.55. TEMPLATE_STRING_IF_INVALID
D.4.56. TEST_DATABASE_NAME
D.4.57. TEST_RUNNER
D.4.58. TIME_FORMAT
D.4.59. TIME_ZONE
D.4.60. URL_VALIDATOR_USER_AGENT
D.4.61. USE_ETAGS
D.4.62. USE_I18N
D.4.63. YEAR_MONTH_FORMAT
E. Built-in Template Tags and Filters
E.1. Built-in Tag Reference
E.1.1. autoescape
E.1.2. block
E.1.3. comment
E.1.4. cycle
E.1.5. debug
E.1.6. extends
E.1.7. filter
E.1.8. firstof
E.1.9. for
E.1.10. if
E.1.11. ifchanged
E.1.12. ifequal
E.1.13. ifnotequal
E.1.14. include
E.1.15. load
E.1.16. now
E.1.17. regroup
E.1.18. spaceless
E.1.19. ssi
E.1.20. templatetag
E.1.21. url
E.1.22. widthratio
E.1.23. with
E.2. Built-in Filter Reference
E.2.1. add
E.2.2. addslashes
E.2.3. capfirst
E.2.4. center
E.2.5. cut
E.2.6. date
E.2.7. default
E.2.8. default_if_none
E.2.9. dictsort
E.2.10. dictsortreversed
E.2.11. divisibleby
E.2.12. escape
E.2.13. escapejs
E.2.14. filesizeformat
E.2.15. first
E.2.16. fix_ampersands
E.2.17. floatformat
E.2.18. force_escape
E.2.19. get_digit
E.2.20. iriencode
E.2.21. join
E.2.22. last
E.2.23. length
E.2.24. length_is
E.2.25. linebreaks
E.2.25.1. linebreaksbr
E.2.26. linenumbers
E.2.27. ljust
E.2.28. lower
E.2.29. make_list
E.2.30. phone2numeric
E.2.31. pluralize
E.2.32. pprint
E.2.33. random
E.2.34. removetags
E.2.35. rjust
E.2.36. safe
E.2.37. safeseq
E.2.38. slice
E.2.39. slugify
E.2.40. stringformat
E.2.41. striptags
E.2.42. time
E.2.43. timesince
E.2.44. timeuntil
E.2.45. title
E.2.46. truncatewords
E.2.47. truncatewords_html
E.2.48. unordered_list
E.2.49. upper
E.2.50. urlencode
E.2.51. urlize
E.2.52. urlizetrunc
E.2.53. wordcount
E.2.54. wordwrap
E.2.55. yesno
F. The django-admin Utility
F.1. Usage
F.1.1. Getting Runtime Help
F.1.2. App Names
F.1.3. Determining the Version
F.1.4. Displaying Debug Output
F.2. Available Subcommands
F.2.1. cleanup
F.2.2. compilemessages
F.2.2.1. --locale
F.2.3. createcachetable
F.2.4. createsuperuser
F.2.5. dbshell
F.2.6. diffsettings
F.2.7. dumpdata
F.2.8. flush
F.2.9. inspectdb
F.2.10. loaddata <fixture fixture ...>
F.2.10.1. What's a Fixture?
F.2.10.2. Compressed Fixtures
F.2.11. makemessages
F.2.11.1. --all
F.2.11.2. --extension
F.2.11.3. --locale
F.2.11.4. --domain
F.2.12. reset <appname appname ...>
F.2.12.1. --noinput
F.2.13. runfcgi [options]
F.2.14. runserver
F.2.14.1. Examples of Using Different Ports and Addresses
F.2.14.2. Serving Static Files with the Development Server
F.2.15. shell
F.2.16. sql <appname appname ...>
F.2.17. sqlall <appname appname ...>
F.2.18. sqlclear <appname appname ...>
F.2.19. sqlcustom <appname appname ...>
F.2.20. sqlflush
F.2.21. sqlindexes <appname appname ...>
F.2.22. sqlreset <appname appname ...>
F.2.23. sqlsequencereset <appname appname ...>
F.2.24. startapp <appname>
F.2.25. startproject <projectname>
F.2.26. syncdb
F.2.26.1. --noinput
F.2.27. test
F.2.27.1. --noinput
F.2.28. testserver <fixture fixture ...>
F.2.29. validate
F.3. Default Options
F.3.1. --pythonpath
F.3.2. --settings
F.3.3. --traceback
F.3.4. --verbosity
F.4. Extra Niceties
F.4.1. Syntax Coloring
F.4.2. Bash Completion
G. Request and Response Objects
G.1. HttpRequest
G.1.1. QueryDict Objects
G.1.2. A Complete Example
G.2. HttpResponse
G.2.1. Construction HttpResponses
G.2.2. Setting Headers
G.2.3. HttpResponse Subclasses
G.2.4. Returning Errors
G.2.5. Customizing the 404 (Not Found) View
G.2.6. Customizing the 500 (Server Error) View
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
12. Deploying Django
Next
Next Chapter
13. Generating Non-HTML Content
Part 3. Other Django Features
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset