E-Book Overview
Django for Beginners takes you from total beginner to confident Django developer. Proceed step-by-step through five progressively more complex web applications: from a "Hello World" app all the way to a robust Newspaper app with a custom user model, complete user authentication flow, foreign key relationships, and more. Learn current best practices around class-based views, templates, urls, user authentication, testing, and deployment. The material is up-to-date with the latest versions of both Django (2.0) and Python (3.6). TABLE OF CONTENTS: * Introduction * Chapter 1: Initial Setup * Chapter 2: Hello World app * Chapter 3: Pages app * Chapter 4: Message Board app * Chapter 5: Blog app * Chapter 6: Forms * Chapter 7: User Accounts * Chapter 8: Custom User Model * Chapter 9: User Authentication * Chapter 10: Bootstrap * Chapter 11: Password Change and Reset * Chapter 12: Email * Chapter 13: Newspaper app * Chapter 14: Permissions and Authorizations * Chapter 15: Comments * Conclusion
E-Book Content
Django for Beginners Learn web development with Django 2.0 William S. Vincent © 2018 William S. Vincent
Contents Introduction Why Django Why this book Book Structure Book layout Conclusion
1 1 3 3 5 7
Chapter 1: Initial Setup The Command Line Install Python 3 on Mac OS X Install Python 3 on Windows Install Python 3 on Linux Virtual Environments Install Django Install Git Text Editors Conclusion
8 8 11 13 14 15 16 20 21 21
Chapter 2: Hello World app Initial Setup Create an app Views and URLConfs Hello, world! Git Bitbucket Conclusion
22 22 25 27 30 31 33 37
Chapter 3: Pages app Initial Setup Templates Class-Based Views URLs Add an About Page
39 39 41 44 45 47
CONTENTS
Extending Templates Tests Git and Bitbucket Local vs Production Heroku Additional Files Deploy Conclusion Chapter 4: Message Board app Initial Setup Create a database model Activating models Django Admin Views/Templates/URLs Adding new posts Tests Bitbucket Heroku configuration Heroku deployment Conclusion
49 52 54 56 57 58 61 64 65 65 68 69 70 77 81 85 90 91 93 95
Chapter 5: Blog app Initial Setup Database Models Admin URLs Views Templates Static files Individual blog pages Tests Git Conclusion
96 96 98 100 105 107 108 111 116 122 125 125
Chapter 6: Forms Forms Update Form Delete View Tests Conclusion
127 127 138 145 151 155
Chapter 7: User Accounts
156
CONTENTS
Login Updated homepage Logout link Signup Bitbucket Heroku config Heroku deployment Conclusion
156 159 161 164 170 171 173 177
Chapter 8: Custom User Model Setup Custom User Model Forms Superuser Conclusion
178 178 180 182 185 187
Chapter 9: User Authentication Templates URLs Admin Conclusion
188 188 192 197 203
Chapter 10: Bootstrap Pages app Tests Bootstrap Signup Form Next Steps
204 204 208 211 219 224
Chapter 11: Password Change and Reset Password Change Customizing password change Password reset Custom Templates Conclusion
226 226 228 231 235 240
Chapter 12: Email SendGrid Custom emails Conclusion
241 241 246 250
Chapter 13: Newspaper app Articles app
251 251
CONTENTS
URLs and Views Edit/Delete Create page Conclusion
257 262 268 276
Chapter 14: Permissions and Authorization Improved CreateView Authorizations Mixins Updating views Conclusion
277 277 279 281 283 285
Chapter 15: Comments Model Admin Template Conclusion
286 286 288 295 299
Conclusion Django Resources Python Books Blogs to Follow Feedback
301 302 302 303 303
Introduction Welcome to Django for Beginners, a proje