ebook img

Django for Beginners: Build websites with Python & Django PDF

306 Pages·2022·11.466 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Django for Beginners: Build websites with Python & Django

Django for Beginners Build websites with Python & Django William S. Vincent Thisbookisforsaleathttp://leanpub.com/djangoforbeginners Thisversionwaspublishedon2022-03-24 ThisisaLeanpubbook.LeanpubempowersauthorsandpublisherswiththeLeanPublishing process.LeanPublishingistheactofpublishinganin-progressebookusinglightweighttools andmanyiterationstogetreaderfeedback,pivotuntilyouhavetherightbookandbuild tractiononceyoudo. ©2018-2022WilliamS.Vincent Also By William S. Vincent DjangoforAPIs DjangoforProfessionals Contents Introduction 1 WhyDjango 1 WhyThisBook 2 Prerequisites 3 BookStructure 3 BookLayout 4 AdviceonGettingStuck 5 Community 6 Conclusion 6 Chapter1:InitialSetUp 7 TheCommandLine 7 ShellCommands 9 InstallPython3onWindows 12 InstallPython3onMac 13 PythonInteractiveMode 14 VirtualEnvironments 14 InstallDjango 17 FirstDjangoProject 19 TextEditors 22 InstallGit 23 Conclusion 25 Chapter2:HelloWorldApp 26 InitialSetUp 26 CONTENTS HTTPRequest/ResponseCycle 32 Model-View-ControllervsModel-View-Template 33 CreateAnApp 34 Hello,World 36 Git 40 GitHub 42 SSHKeys 43 Conclusion 44 Chapter3:PagesApp 45 InitialSetUp 45 Templates 48 Class-BasedViews 49 URLs 50 AboutPage 51 ExtendingTemplates 53 Tests 55 GitandGitHub 60 LocalvsProduction 62 Heroku 62 DeploymentChecklist 64 Conclusion 69 Chapter4:MessageBoardApp 70 InitialSetUp 70 CreateaDatabaseModel 73 Activatingmodels 74 DjangoAdmin 75 Views/Templates/URLs 80 AddingNewPosts 83 Tests 84 GitHub 88 HerokuConfiguration 89 CONTENTS HerokuDeployment 90 Conclusion 91 Chapter5:BlogApp 92 InitialSetUp 92 DatabaseModels 95 Admin 96 URLs 100 Views 101 Templates 102 StaticFiles 104 IndividualBlogPages 109 Tests 113 Git 117 Conclusion 118 Chapter6:Forms 119 CreateView 119 UpdateView 125 DeleteView 129 Tests 134 Conclusion 136 Chapter7:UserAccounts 137 LogIn 137 UpdatedHomepage 140 LogOutLink 141 SignUp 144 SignUpLink 149 GitHub 150 StaticFiles 151 HerokuConfig 154 HerokuDeployment 155 CONTENTS SQLitevsPostgreSQL 156 Conclusion 157 Chapter8:CustomUserModel 158 InitialSetUp 158 CustomUserModel 159 Forms 161 Superuser 164 Conclusion 168 Chapter9:UserAuthentication 169 Templates 169 URLs 172 Admin 176 Tests 181 Conclusion 183 Chapter10:Bootstrap 184 PagesApp 184 Tests 187 TestingPhilosophy 188 Bootstrap 188 SignUpForm 193 Conclusion 198 Chapter11:PasswordChangeandReset 199 PasswordChange 199 CustomizingPasswordChange 200 PasswordReset 203 CustomTemplates 207 TryItOut 210 Conclusion 212 Chapter12:Email 213 CONTENTS SendGrid 213 CustomEmails 220 Conclusion 222 Chapter13:NewspaperApp 223 ArticlesApp 223 URLsandViews 227 Detail/Edit/Delete 231 CreatePage 237 Conclusion 242 Chapter14:PermissionsandAuthorization 243 ImprovedCreateView 243 Authorizations 245 Mixins 247 LoginRequiredMixin 249 UpdateViewandDeleteView 251 Conclusion 253 Chapter15:Comments 254 Model 254 Admin 255 Template 264 CommentForm 268 CommentView 269 CommentTemplate 270 CommentPostView 272 Conclusion 277 Chapter16:Deployment 278 EnvironmentVariables 279 DEBUG&ALLOWEDHOSTS 281 SECRET_KEY 284 CONTENTS DATABASES 285 StaticFiles 287 DeploymentChecklist 289 GitHub 291 HerokuDeployment 291 Conclusion 294 Conclusion 295 NextSteps 295 3rdPartyPackages 296 LearningResources 296 PythonBooks 297 Feedback 297 Introduction WelcometoDjangoforBeginners,aproject-basedapproachtolearningwebdevelopmentwith the Django1 web framework. In this book you will build five progressively more complex web applications,startingwithasimpleHello,Worldapp,progressingtoaPagesapp,aMessageBoard app,aBlogappwithformsanduseraccounts,andfinallyaNewspaperappthatusesacustom user model, email integration, foreign keys, authorization, permissions, and more. By the end of this book you should feel confident creating your own Django projects from scratch using currentbestpractices. Djangoisafree,opensourcewebframeworkwritteninthePythonprogramminglanguage.First releasedin2005,Djangohasbeenincontinuousdevelopmentsincethenandtodaypowersmany ofthelargestwebsitesintheworldincludingInstagram,Pinterest,Bitbucket,andDisqus.Atthe sametime,itisflexibleenoughtobeapopularchoiceforearly-stagestartupsandsideprojects. Why Django A “web framework” is a collection of tools that abstract away much of the difficulty–and repetition–inherent in web development. For example, most websites need the same basic functionality: the ability to connect to a database, set URL routes, display content on a page, handlesecurityproperly,andsoon.Ratherthanrecreateallofthisfromscratch,programmers overtheyearshavecreatedwebframeworksinallthemajorprogramminglanguages:Djangoin Python,RailsinRuby,andLaravelinPHPamongmany,manyothers. DjangoinheritedPython’s“batteries-included”approachandincludesout-of-theboxsupport forcommontasksinwebdevelopment,including: • userauthentication • testing 1https://djangoproject.com

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.