Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf.pdf

所需积分/C币:9 2019-09-14 16:56:14 10.63MB PDF
53
收藏 收藏
举报

Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf
Beginning Django: Web Application Development and Deployment with Python Daniel rubio F Bahia, Ensenada, Baja California, Mexico ISBN-13(pbk):978-1-48422786-2 ISBN-13( electronic):978-1-4842-2787-9 htps:/ doi. org/10.1007/978-1-48422787-9 Library of Congress Control Number: 2017958633 Copyright o 2017 by Daniel rubic This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein CoverimagebyFreepik(www.freepik.com Managing director: Welmoed spahr Editorial Director: Todd green Acquisitions Editor: Steve anglin Development Editor: Matthew Moodie Technical reviewer: Tri Phan Coordinating editor: Mark Powers Copy Editor: Karen Jameson Distributed to the book trade worldwide by springer science+Business Media New York 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax(201)348-4505, e-mail orders-ny@springer-sbm.comorvisitwww.springeronline.comApressMedia,LlcisaCaliforniaLlc and the sole member(owner )is Springer Science+ Business Media Finance Inc(SSBM Finance Inc) SSBM Finance Inc is a Delaware corporation Forinformationontranslationspleasee-mailrightsqapress.comorvisithttp://www.apress.com/ rights-permissions Apress titles may be purchased in bulk for academic, corporate, or promotional use eBook versions and licenses are also available for most titles. For more information reference our print and ebook bulk Saleswebpageathttp://www.apress.com/bulk-sales Any source code or other supplementary material referenced by the author in this book is available to readersonGithubviathebooksproductpagelocatedatwww.apress.com/9781484227862.Formore detailedinformationpleasevisithttp://www.apress.com/source-code Printed on acid-free paper To Valentina, Nancy and all my immediate family To my uncle alfonso, whose Commodore 64 let me gain an affinit for technology Contents at a glance About the author xxI About the technical reviewer Acknowledgments mmmmmaammmaaammmaaammeamanmmaanmamaaammaaamaaa.XXV Introduction ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ XXVI Chapter 1: Introduction to the Django Framework Chapter 2: Django Urls and views a ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■圈 31 Chapter3: Django Templates,,,,,…,…,,,,,,…73 Chapter 4: Jinja Templates in Django ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 117 Chapter 5: Django Application Management meant ■■■■■■■■■■■■■ u163 Chapter6: Django Forms…,,,…,,,,,,,,,,,1,,,1,217 Chapter 7: Diango Models mmmaammmmmmmmmmm 275 Chapter 8: Django Model queries and Managers ammmmmmmmmmmmmamaaan 341 Chapter 9: Django Model Forms and class views mammar ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 403 Chapter 10: Django User Management.mar ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 441 Chapter 11: Django admin Management 495 Chapter 12: REST Services with Django ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■口■■■■■■ 549 Appendix A: Python Basics. mammmmmmmmmma 567 Index 585 Contents About the author xxI About the technical reviewer Acknowledgments mmmmmaammmaaammmaaammeamanmmaanmamaaammaaamaaa.XXV Introduction mmm xxvii Chapter 1: Introduction to the Django Framework Django framework Design Principles Don't Repeat Yourself(DRY) Principle.... 22 Explicit Is Better Than Implicit mosely Coupled Architecture.............. 5 Install Django 5 Install Python( Prerequisite 6 Update or Install pip Package Manager( Prerequisite)…..,.,……,7 Install virtualenv(optional Prerequisite Install diango Install Django from Git Start a Django Project 13 Set Up a Database for a Django Project 15 nstall Python Database Packages..,.,…,,……18 Test Django Database Connection and build django Base Tables ,18 Set Up Content: Understand Urls, Templates, and Create and configure Django Urls…....… Create and configure Django Templates Create and Configure Django Apps..................... CONTENTS Set Up the django admin site Configure and Install the Django admin site App . 52 Configure and Install the Django admin site docs App Chapter 2: Django Urls and Views a BRBRBRRBBRBRRRIEE Url Regular Expressions…..,.,.,.,.,,,,… 31 Precedence rule: granular urls first Broad urls last Exact Url Patterns: Forgoing Broad Matching 32 Common url Patterns Url Parameters, Extra Options, and Query Strings 35 Url Consolidation and modularization 38 Url Naming and Namespaces 40 View Method Requestsa.........aeaea 47 View Method Responses Response Options for Http Status and Content-type Headers Built-in Response Shortcuts and Templates for Common Http Status 404(not Found) 500(Internal Server Error), 400 Bad Request Built-In Response shortcuts for Inline and streamed content 55 View Method Middleware 57 Built-In Middleware Classes 57 Middlewarestructureandexecutionprocesswwwwwwww.60 Middleware Flash Messages in view Methods 64 Add Flash Messages Access Flash Messages 67 Class-Based views 68 Built-inclass-basedviews.wwwwwwwww.69 Class-Based view structure and execution CONTENTS Chapter 3: Django Templates. aaeameaeaseammamaamaaamamat 73 Django Template Syntax 73 Auto-Escaping: HTML and Erring on the Safe Side Django Template Configuration 75 Template Search Paths…,…… ……….76 Invalid Template variables........................ 78 Debug output.… Auto-Escape File charset.… 82 Automatic Access to Custom Template tag/filter Modules..................83 Template Loaders…..,.,.,.,.,.,,.,… Create Reusable Templates........ .................................................................85 Built-In Context Django debug context processor( django. template. context_processors. debug)…………88 Django request context processor( django. template context_processors. request)……………,18 Django auth context processor (django. contrib. auth. context_processors. auth) Django messages context processor (django. contrib. messages. context_processors. messages)..89 Other Built-In Django Context Processors: i18n, media, static, tz, and cSrF context Processors..89 Custom context processors 90 uilt-In Django Filters.… 91 Dates…91 Strings, Lists, and Numbers Numbers ,m.m.. 5889 Lists and dictionaries. Spacing and Special Characters Development and Testing .................................................100 Urls 101 Built-In Django tags DDDDDDDDDDDDDDDDDDDDDDDBDDDDDDDDDDDDBDBDDD 101 Dates… 102 CONTENTS Comparison Operations 102 L00pS….,,,,…,,… 104 Python and Filter Operations…..,,…,………………107 Spacing and special characters.. 108 Template Structures… 109 Development and testing 110 Urls 110 Custom filters……110 Structurewwwwwwwww.110 Options: Naming, HTML, and What Comes In and Out ... 112 Installation and Access 114 Chapter 4: Jinja Templates in Django aIM: 117 Jinja advantages and Disadvantages.mm.aemnmnn 117 Transition to Jinja Templates from Django Templates. What Works the Same Way in Jinja and Django Templates 118 What Works Differently in Jinja templates compared to Django Templates............. 19 New Concepts and Features in Jinja Templates vS. Django Templates................ 121 Jinja Template Configuration in Django 123 Template Search Paths……,… 123 Auto-Escaping Behavior 00000000000000000000000000000000000000000000000000000000000000 125 Aut- Reload Template Behavior and Caching………126 Invalid Template Variables 127 Template Loaders 128 Create Reusable Jinja Templates . 128 Jinja Globals: Access Data on All Jinja Templates, Like Django Context Processors.n. 134 Jinja built-In statements/Tags and Functions Like Django Template Tags) 135 Comparison operations ....................................................................................136 Loops 137 CONTENTS Python and Filter operations ............................... 141 Spacing and Special Characters........ 142 Template Structures…..…145 Jinja built-In Filters and Tests like Django Filters .146 Strings, Lists, Dictionaries, Numbers, and objects Strings and lists .. Dictionaries and Objects... 149 Strings 151 Numbers 152 Spacing and special characters . Development and Testing 155 UrlS…, 155 Custom Filters and Tests in Jinja 156 Structure 156 Installation and access Jinja Extensions 158 Enable Jinja Extensions 159 Create Jinja Extensions……,… 160 Jinja policies ……………….161 Chapter 5: Django Application Management mnan mmmm 163 Django settings. py for the Real World 163 Switch debug to False 163 Defineallowedhosts.wwwwww.164 Be careful with the secret Key value Define administrators for admins and managers 165 Use Dynamic Abso| ute Paths…..,…….166 Use Multiple Environments or Configuration Files for Django. ...........................................168 Set Up Static Web Page Resources-Images, CSS, JavaScript 173 Set Up static Resources in a Development environment (dEBUG=False) 173 Access Static Resources in Django Templates...........................176

...展开详情
试读 127P Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf.pdf
立即下载
限时抽奖 低至0.43元/次
身份认证后 购VIP低至7折
一个资源只可评论一次,评论内容不能少于5个字
您会向同学/朋友/同事推荐我们的CSDN下载吗?
谢谢参与!您的真实评价是我们改进的动力~
  • 至尊王者

关注 私信
上传资源赚钱or赚积分
最新推荐
Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf.pdf 9积分/C币 立即下载
1/127
Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf.pdf第1页
Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf.pdf第2页
Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf.pdf第3页
Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf.pdf第4页
Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf.pdf第5页
Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf.pdf第6页
Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf.pdf第7页
Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf.pdf第8页
Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf.pdf第9页
Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf.pdf第10页
Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf.pdf第11页
Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf.pdf第12页
Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf.pdf第13页
Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf.pdf第14页
Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf.pdf第15页
Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf.pdf第16页
Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf.pdf第17页
Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf.pdf第18页
Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf.pdf第19页
Beginning-Django-Web-Application-Development-and-Deployment-with-Python.pdf.pdf第20页

试读结束, 可继续阅读

9积分/C币 立即下载