E-Book, Englisch, 447 Seiten
Kaplan-Moss / Holovaty The Definitive Guide to Django
1. ed
ISBN: 978-1-4302-0331-5
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
Web Development Done Right
E-Book, Englisch, 447 Seiten
ISBN: 978-1-4302-0331-5
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
Django, the Python-based Web development framework, is one of the hottest topics in Web development today. Its creator (and co-author of this book) Adrian Holovaty has built a compelling array of Web applications using Django, including http://chicagocrime.org. Django creator Adrian Holovaty and lead developer Jacob Kaplan-Moss have created this book as the definitive guide to the technology. Beginning with fundamentals such as installation and configuration, the book tackles sophisticated features of Django, such as outputting non-HTML content such as RSS feeds and PDFs, caching, and user management. Also includes a detailed reference to Django's many configuration options and commands.
Jacob Kaplan-Moss is one of the lead developers of Django. At his day job, he's the lead developer for the Lawrence Journal-World, a locally owned newspaper in Lawrence, Kansas, where Django was developed. At the Journal-World, Jacob hacks on a number of sites including lawrence.com, LJWorld.com, and KUsports.com, and he is continually embarrassed by the multitude of media awards those sites win. In his spare time what little of it there is he fancies himself a chef.
Autoren/Hrsg.
Weitere Infos & Material
1;Contents at a Glance;4
2;Contents;6
3;About the Authors;26
4;About the Technical Reviewer;27
5;Acknowledgments;28
6;Introduction;29
7;Getting Started;31
7.1;Introduction to Django;32
7.1.1;What Is a Web Framework?;32
7.1.2;The MVC Design Pattern;34
7.1.3;Django’s History;35
7.1.4;How to Read This Book;36
7.1.5;What’s Next?;38
7.2;Getting Started;39
7.2.1;Installing Python;39
7.2.2;Installing Django;39
7.2.3;Setting Up a Database;41
7.2.4;Starting a Project;42
7.2.5;What’s Next?;44
7.3;The Basics of Dynamic Web Pages;45
7.3.1;Your First View: Dynamic Content;45
7.3.2;Mapping URLs to Views;46
7.3.3;How Django Processes a Request;49
7.3.4;URLconfs and Loose Coupling;51
7.3.5;404 Errors;51
7.3.6;Your Second View: Dynamic URLs;52
7.3.7;Django’s Pretty Error Pages;56
7.3.8;What’s Next?;58
7.4;The Django Template System;59
7.4.1;Template System Basics;59
7.4.2;Using the Template System;61
7.4.3;Basic Template Tags and Filters;68
7.4.4;Philosophies and Limitations;75
7.4.5;Using Templates in Views;76
7.4.6;Template Loading;77
7.4.7;Template Inheritance;82
7.4.8;What’s Next?;86
7.5;Interacting with a Database: Models;87
7.5.1;The “ Dumb” Way to Do Database Queries in Views;87
7.5.2;The MTV Development Pattern;88
7.5.3;Configuring the Database;90
7.5.4;Your First App;92
7.5.5;Defining Models in Python;93
7.5.6;Your First Model;94
7.5.7;Installing the Model;96
7.5.8;Basic Data Access;99
7.5.9;Adding Model String Representations;100
7.5.10;Inserting and Updating Data;101
7.5.11;Selecting Objects;102
7.5.12;Deleting Objects;106
7.5.13;Making Changes to a Database Schema;107
7.5.14;What’s Next?;110
7.6;The Django Administration Site;111
7.6.1;Activating the Admin Interface;111
7.6.2;Using the Admin Interface;113
7.6.3;Customizing the Admin Interface;119
7.6.4;Customizing the Admin Interface’s Look and Feel;121
7.6.5;Customizing the Admin Index Page;121
7.6.6;When and Why to Use the Admin Interface;122
7.6.7;What’s Next?;122
7.7;Form Processing;123
7.7.1;Search;123
7.7.2;The “ Perfect Form”;126
7.7.3;Creating a Feedback Form;126
7.7.4;Processing the Submission;129
7.7.5;Custom Validation Rules;131
7.7.6;A Custom Look and Feel;131
7.7.7;Creating Forms from Models;133
7.7.8;What’s Next?;134
7.8;Advanced Views and URLconfs;135
7.8.1;URLconf Tricks;135
7.8.2;Including Other URLconfs;148
7.8.3;What’s Next?;150
8;Django’s Subframeworks;151
8.1;Generic Views;152
8.1.1;Using Generic Views;152
8.1.2;Generic Views of Objects;154
8.1.3;Extending Generic Views;155
8.1.4;What’s Next?;160
8.2;Extending the Template Engine;161
8.2.1;Template Language Review;161
8.2.2;RequestContext and Context Processors;162
8.2.3;Inside Template Loading;167
8.2.4;Extending the Template System;168
8.2.5;Writing Custom Template Loaders;178
8.2.6;Using the Built- in Template Reference;180
8.2.7;Configuring the Template System in Standalone Mode;180
8.2.8;What’s Next?;181
8.3;Generating Non-HTML Content;182
8.3.1;The Basics: Views and MIME Types;182
8.3.2;Producing CSV;183
8.3.3;Generating PDFs;184
8.3.4;Other Possibilities;187
8.3.5;The Syndication Feed Framework;187
8.3.6;The Sitemap Framework;194
8.3.7;What’s Next?;199
8.4;Sessions, Users, and Registration;200
8.4.1;Cookies;200
8.4.2;Django’s Session Framework;203
8.4.3;Users and Authentication;208
8.4.4;The Other Bits: Permissions, Groups, Messages, and Profiles;218
8.4.5;What’s Next?;221
8.5;Caching;222
8.5.1;Setting Up the Cache;223
8.5.2;The Per- Site Cache;226
8.5.3;The Per- View Cache;227
8.5.4;The Low- Level Cache API;228
8.5.5;Upstream Caches;229
8.5.6;Other Optimizations;233
8.5.7;Order of MIDDLEWARE_ CLASSES;233
8.5.8;What’s Next?;233
8.6;Other Contributed Subframeworks;234
8.6.1;The Django Standard Library;234
8.6.2;Sites;235
8.6.3;Flatpages;241
8.6.4;Redirects;244
8.6.5;CSRF Protection;246
8.6.6;Form Tools;248
8.6.7;Humanizing Data;250
8.6.8;Markup Filters;251
8.6.9;What’s Next?;251
8.7;Middleware;252
8.7.1;What’s Middleware?;252
8.7.2;Middleware Installation;253
8.7.3;Middleware Methods;254
8.7.4;Built- in Middleware;255
8.7.5;What’s Next?;258
8.8;Integrating with Legacy Databases and Applications;259
8.8.1;Integrating with a Legacy Database;259
8.8.2;Integrating with an Authentication System;261
8.8.3;Integrating with Legacy Web Applications;263
8.8.4;What’s Next?;264
8.9;Extending Django’s Admin Interface;265
8.9.1;The Zen of Admin;266
8.9.2;Customizing Admin Templates;267
8.9.3;Creating Custom Admin Views;270
8.9.4;Overriding Built- in Views;273
8.9.5;What’s Next?;273
8.10;Internationalization;274
8.10.1;Specifying Translation Strings in Python Code;275
8.10.2;Specifying Translation Strings in Template Code;277
8.10.3;Creating Language Files;279
8.10.4;How Django Discovers Language Preference;281
8.10.5;The set_ language Redirect View;283
8.10.6;Using Translations in Your Own Projects;284
8.10.7;Translations and JavaScript;285
8.10.8;Notes for Users Familiar with gettext;287
8.10.9;What’s Next?;287
8.11;Security;288
8.11.1;The Theme of Web Security;288
8.11.2;SQL Injection;289
8.11.3;Cross- Site Scripting;290
8.11.4;Cross- Site Request Forgery;292
8.11.5;Session Forging/ Hijacking;292
8.11.6;Email Header Injection;294
8.11.7;Directory Traversal;294
8.11.8;Exposed Error Messages;296
8.11.9;A Final Word on Security;296
8.11.10;What’s Next?;296
8.12;Deploying Django;297
8.12.1;Shared Nothing;298
8.12.2;A Note on Personal Preferences;300
8.12.3;Using Django with Apache and mod_ python;300
8.12.4;Using Django with FastCGI;304
8.12.5;Scaling;310
8.12.6;Performance Tuning;315
8.12.7;What’s Next?;316
9;Appendixes;317
9.1;Case Studies;318
9.1.1;Cast of Characters;318
9.1.2;Why Django?;320
9.1.3;Getting Started;320
9.1.4;Porting Existing Code;321
9.1.5;How Did It Go?;321
9.1.6;Team Structure;323
9.1.7;Deployment;324
9.2;Model Definition Reference;325
9.2.1;Fields;325
9.2.2;Universal Field Options;330
9.2.3;Relationships;334
9.2.4;Model Metadata Options;337
9.2.5;Managers;340
9.2.6;Model Methods;343
9.2.7;Admin Options;346
9.3;Database API Reference;353
9.3.1;Creating Objects;354
9.3.2;Saving Changes to Objects;355
9.3.3;Retrieving Objects;356
9.3.4;Caching and QuerySets;357
9.3.5;Filtering Objects;357
9.3.6;Field Lookups;366
9.3.7;Complex Lookups with Q Objects;370
9.3.8;Related Objects;371
9.3.9;Deleting Objects;375
9.3.10;Extra Instance Methods;376
9.3.11;Shortcuts;377
9.3.12;Falling Back to Raw SQL;378
9.4;Generic View Reference;379
9.4.1;Common Arguments to Generic Views;379
9.4.2;“ Simple” Generic Views;380
9.4.3;List/ Detail Generic Views;381
9.4.4;Date- Based Generic Views;385
9.4.5;Create/ Update/ Delete Generic Views;395
9.5;Settings;399
9.5.1;What’s a Settings File?;399
9.5.2;Designating the Settings: DJANGO_ SETTINGS_ MODULE;401
9.5.3;Using Settings Without Setting DJANGO_ SETTINGS_ MODULE;402
9.5.4;Available Settings;403
9.6;Built-in Template Tags and Filters;415
9.6.1;Built- in Tag Reference;415
9.6.2;Built- in Filter Reference;425
9.7;The django-admin Utility;435
9.7.1;Usage;435
9.7.2;Available Actions;436
9.7.3;Available Option;441
9.8;Request and Response Objects;444
9.8.1;HttpRequest;444
9.8.2;HttpResponse;448
10;Index;452




