Book description
'Lead developer Jacob Kaplan-Moss and Django creator Adrian Holovaty show you how they use this framework to create award-winning web sites by guiding you through the creation of a web application reminiscent of www.chicagocrime.org.
Table of contents
- Copyright
- About the Authors
- About the Technical Reviewer
- Acknowledgments
- Preface
- Introduction
-
1. Getting Started
- 1. Introduction to Django
- 2. Getting Started
- 3. Views and URLconfs
- 4. Templates
-
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.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.7. Customizing Field Labels
- 6.8. Custom ModelAdmin Classes
- 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
-
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.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.3. What's Next?
-
8.1. URLconf Tricks
-
9. Advanced Templates
- 9.1. Template Language Review
- 9.2. RequestContext and Context Processors
- 9.3. Automatic HTML Escaping
- 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
- 11. Generic Views
-
12. Deploying Django
- 12.1. Preparing Your Codebase for Production
- 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.6. Scaling
- 12.7. Performance Tuning
- 12.8. What's Next?
-
8. Advanced Views and URLconfs
-
3. Other Django Features
- 13. Generating Non-HTML Content
-
14. Sessions, Users, and Registration
- 14.1. Cookies
- 14.2. Django's Session Framework
- 14.3. Users and Authentication
- 14.4. Permissions, Groups, and Messages
- 14.5. What's Next?
-
15. Caching
- 15.1. Setting Up the Cache
- 15.2. The Per-Site Cache
- 15.3. The Per-View Cache
- 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.3. Flatpages
- 16.4. Redirects
- 16.5. CSRF Protection
- 16.6. Humanizing Data
- 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.5. What's Next?
- 18. Integrating with Legacy Databases and Applications
-
19. Internationalization
- 19.1. How to Specify Translation Strings
- 19.2. How to Create Language 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.7. Notes for Users Familiar with gettext
- 19.8. gettext on Windows
- 19.9. What's Next?
- 20. Security
-
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.3. Relationships
- A.4. Model Metadata Options
-
A.1. Fields
-
B. Database API Reference
- B.1. Creating Objects
- B.2. Saving Changes to Objects
- B.3. Retrieving Objects
- B.4. Caching and QuerySets
- B.5. Filtering Objects
- B.6. Field Lookups
- B.7. Complex Lookups with Q Objects
- B.8. Related Objects
- B.9. Deleting Objects
- B.10. Shortcuts
- B.11. Falling Back to Raw SQL
- C. Generic View Reference
-
D. Settings
- D.1. The Basics of Settings Files
- D.2. Designating the Settings: DJANGO_SETTINGS_MODULE
- D.3. Using Settings Without Setting DJANGO_SETTINGS_MODULE
-
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.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
-
E.1. Built-in Tag Reference
-
F. The django-admin Utility
- F.1. Usage
-
F.2. Available Subcommands
- F.2.1. cleanup
- F.2.2. compilemessages
- 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.11. makemessages
- F.2.12. reset <appname appname ...>
- F.2.13. runfcgi [options]
- F.2.14. runserver
- 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.27. test
- F.2.28. testserver <fixture fixture ...>
- F.2.29. validate
- F.3. Default Options
- F.4. Extra Niceties
- G. Request and Response Objects
-
A. Model Definition Reference
Product information
- Title: The Definitive Guide to Django: Web Development Done Right, Second Edition
- Author(s):
- Release date: July 2009
- Publisher(s): Apress
- ISBN: 9781430219361
You might also like
book
The Definitive Guide to Django: Web Development Done Right
Django, the Python-based equivalent to the Ruby on Rails web development framework, is hottest topics in …
book
Pro Django, Second Edition
Learn how to leverage Django, the leading Python web application development framework, to its full potential …
book
Django 2 Web Development Cookbook - Third Edition
Create unbelievably fast, robust and secure web apps with Django Web Framework and Python 3.8 Key …
book
Practical Django Projects, Second Edition
Build a Django content management system, blog, and social networking site with James Bennett as he …