上传者: 只为 上传时间: 2021-02-18 23:37:13 文件大小: 4.71MB 文件类型: -
Web Development with Django Cookbook 第2版This is the latest book on the market that will help you take advantage of the new features added to Django 1.8 This book consists of recipes of varying complexities to help you create multilingual, responsive, and scalable websi
Web Development with Django CookbookSecond editionCopyright C 2016 Packt PublishingAll rights reserved No part of this book may be reproduced, stored in a retrieval system, ortransmitted in any form or by any means, without the prior written permission of the publisher,except in the case of brief quotations embedded in critical articles or reviewsEvery effort has been made in the preparation of this book to ensure the accuracy of theinformation presented. However, the information contained in this book is sold withoutwarranty, either express or implied. Neither the author, nor Packt Publishing, and its dealersand distributors will be held liable for any damages caused or alleged to be caused directly orindirectly by this bookPackt Publishing has endeavored to provide trademark information about all of the companiesand products mentioned in this book by the appropriate use of capitals. However, PacktPublishing cannot guarantee the accuracy of this informationFirst published: October 2014Second Edition: January 2016Production reference: 1220116Published by Packt Publishing LtdLivery Place35 Livery StreetBirmingham B3 2PB, UKSBN978-1-78588677-5www.packtpub.comwww.it-ebooksinfoCreditsAuthorProject CoordinatorAidas bendoraitiShweta h birwatkarReviewersProofreaderPatrick ChaSatis editingJake KronikJorge Armin Garcia LopezIndexerMariamman ChettaCommissioning EditorDipika gaonkarProduction coordinatorArvindkumar guptaAcquisition EditorNadeem N BaganCover workArvindkumar GuptaContent development EditorsArwa manasawalaSumeet sawantTechnical editeBharat patilEditVibha shuklaww. it-ebooks infoAbout the AuthorAidas bendoraitis has been professionally working with web technologies for over adecade. Over the past nine years at a berlin-based company, studio 38 pure communicationGmbH, he has developed a number of small-scale and large-scale django projects-mostlyin the cultural area-together with a creative team. at the moment, he is also working as asoftware architect at a London-based mobile startup, Hype.Aidas regularly attends meetups of Django User Group Berlin, occasionally visits DjangoandPythonconferencesandwritesaweblogaboutDjangohttp://djangotrickslogspot. com/I would like to thank my wife, Sofja, for her support and patience whileI was writing this book, even during late evenings and weekends. I wouldalso like to thank studio 38 pure communication GmbH and namelyReinhard Knobelspies for introducing django to me nine years ago. Finally,I would like to thank vilnius University in Lithuania for teaching the mainprogramming concepts, without which I wouldn't be working in the positionsI currently havewww.it-ebooksinfoAbout the reviewersPatrick Chan is a device and configuration management SME (subject matter expertworking in the telecommunication industry. His experience in Python has been instrumental indeveloping build systems that have not only increased developer productivity, but would alsoensure operational reliability by automating software releasesJake Kronika is a passionate full-stack developer with over 20 years of experienceJake's career grew alongside the evolution of the web development space. starting withGeoCities and Angelfire, his skills have gradually expanded from simple HTML and copy andpaste scripts to encapsulate a deep understanding of cSs. Java Script skills that span coreECMAScript standards as well as numerous client-side libraries and powerful frameworkssuch as Node js and AngularJS: scripting languages including python and PHP; and variousdatabases, MySQL and PostgreSQL among themJake is currently senior software engineer with CDK Global Digital Marketing wing and a PHPdeveloper with Webkey LLC Outside these roles, Jake also operates a sole proprietorshipthrough which he provides services spanning the full spectrum of web administration, design,and developmentIn addition to his professional career experience, Jake has acted as a reviewer for numerousther Packt titles, such as Django JavaScript Integration: AJAX and jQuery(2011), jQueryU/ 1.8: The User Interface Library for jQuery(2011),jQuery Tools UI Library(2012), andDeveloping Responsive Web Applications with AJAX and jQuery(2014)I would like to thank my family for their ongoing love and supportwww.it-ebooksinfoJorge armin Garcia Lopez is a very passionate information security consultant fromMexico with more than seven years of experience in computer security, penetration testing,ntrusion detection/prevention, malware analysis, and incident response. He is the head ofGCS-CERT. He is also a security researcher at cipher storm ltd and is the cofounder and ceoof the most important security conference in Mexico, called BugCon. He holds importantsecurity industry certifications such as OSCP, GCIA, and GPENHe loves reviewing code and books about information security and programming languagesHe has worked on the books Penetration Testing with Backbox, Penetration Testing withthe Bash Shell, Learning Open Stack Networking(Neutron), Django Essentials, and GettingStarted with Django, all by Packt Publishingwww.it-ebooksinfowww.packtpub.comSupport files, eBooks, discount offers, and moreForsupportfilesanddownloadsrelatedtoyourbookpleasevisitwww.Packtpub.comDid you know that Packt offers e Book versions of every book published, with PDF and ePubfilesavailableYoucanupgradetotheebookversionatwww.Packtpub.comandasaprintbook customer, you are entitled to a discount on the e Book copy. Get in touch with us atservice@packtpub com for more detailsAtwww.paCktpub.comyoucanalsoreadacollectionoffreetechnicalarticlessignupfor a range of free newsletters and receive exclusive discounts and offers on Packt booksand ebooksTUPACKT LiBhttps://www2.packtpub.com/books/subscription/packtlibDo you need instant solutions to your IT questions? PacktLib is Packt's online digital booklibrary. Here, you can search, access, and read Packt's entire library of books.Why Subscribe?Fully searchable across every book published by packtCopy and paste, print, and bookmark contentb on demand and accessible via a web browserFree Access for packt account holdersIfyouhaveanaccountwithPacktatwww.paCktpub.comyoucanusethistoaccessPacktLib today and view 9 entirely free books Simply use your login credentials forimmediate accesswww.it-ebooksinfowww.it-ebooksinfoTable of contentsPrefaceChapter 1: Getting Started with Django 1.8IntroductionWorking with a virtual environmentCreating a project file structureHandling project dependencies with pip122479MakIng your code compatible wIth both Python 2. 7 and python 3Including external dependencies in your project12Configuring settings for development, testing, staging,and production environments14Defining relative paths in the settings16Creating and including local settings17Setting up stATIC_ URL dynamically for Subversion users19Setting up stATIC_ URL dynamically for Git users20Setting UTF-8 as the default encoding for MysQL configuration22Setting the Subversion ignore property23Creating the Git ignore file26Deleting Python-compiled files28Respecting the import order in Python files29Creating app configuration30Defining overwritable app settings33Chapter 2: Database Structure35Introduction35Using model mixins36Creating a model mixin with URL-related methods37Creating a model mixin to handle creation and modification dates40Creating a model mixin to take care of meta tags42Creating a model mixIn to handle generic relations45www.it-ebooksinfo