Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Django Design Patterns and Best Practices. - Second Edition

You're reading from  Django Design Patterns and Best Practices. - Second Edition

Product type Book
Published in May 2018
Publisher Packt
ISBN-13 9781788831345
Pages 282 pages
Edition 2nd Edition
Languages
Author (1):
Arun Ravindran Arun Ravindran
Profile icon Arun Ravindran
Toc

Table of Contents (21) Chapters close

Title Page
Copyright and Credits
PacktPub.com
Contributors
Preface
1. Django and Patterns 2. Application Design 3. Models 4. Views and URLs 5. Templates 6. Admin Interface 7. Forms 8. Working Asynchronously 9. Creating APIs 10. Dealing with Legacy Code 11. Testing and Debugging 12. Security 13. Production-Ready 1. Python 2 Versus Python 3 2. Other Books You May Enjoy Index

Index

A

  • access controlled views, view patterns
    • issue details / Problem details
    • solution details / Solution details
  • active link, template patterns
    • issue details / Problem details
    • solution details / Solution details
  • admin
    • models, enhancing / Enhancing models for the admin
    • protecting / Protecting the admin
    • feature flags / Pattern – feature flags
  • admin interface
    • using / Using the admin interface
  • admin interface customizations
    • about / Admin interface customizations
    • heading, changed / Changing the heading
    • base and stylesheets, changing / Changing the base and stylesheets
    • Bootstrap-themed admin / Bootstrap-themed admin
    • complete overhauls / Complete overhauls
  • anti-pattern / Are there more patterns?
  • API pattern
    • about / API patterns
    • human browsable interface / Pattern – human browsable interface
    • infinite scrolling / Pattern – Infinite Scrolling
  • assert method / The assert method
  • asynchronous
    • need for / Why asynchronous?
    • code, pitfalls / Pitfalls of asynchronous code
  • asynchronous, pitfalls
    • race condition / Pitfalls of asynchronous code
    • starvation / Pitfalls of asynchronous code
    • deadlock / Pitfalls of asynchronous code
    • debugging challenge / Pitfalls of asynchronous code
    • order preservation / Pitfalls of asynchronous code
  • Asynchronous JavaScript And XML (AJAX) / Solution details
  • asynchronous patterns
    • about / Asynchronous patterns
    • endpoint callback pattern / Endpoint callback pattern
  • asynchronous scraper / Asynchronous web-scraping
  • Asynchronous Server Gateway Interface (ASGI) / Entering Channels
  • asynchronous solutions
    • for Django / Asynchronous solutions for Django
    • Celery / Asynchronous solutions for Django
    • Django channels / Asynchronous solutions for Django
  • asynchronous web-scraping / Asynchronous web-scraping
  • asyncio
    • about / Understanding asyncio
    • versus threads / asyncio versus threads
    • classic web-scraper, example / The classic web-scraper example
    • concurrency / Concurrency is not parallelism
    • parallelism / Concurrency is not parallelism

B

  • backend performance
    • about / Backend performance
    • templates / Templates
    • database / Database
    • caching / Caching
  • base and stylesheets
    • changing / Changing the base and stylesheets
    • rich-text editor, adding for WYSIWYG editing / Adding a rich-text editor for WYSIWYG editing
  • base image / Virtual machines or Docker
  • Berkeley Software Distribution (BSD) / A framework is born
  • Bootstrap
    • using / Using Bootstrap
    • project skeleton, finding / Using Bootstrap
    • package, using / Using Bootstrap
    • manually copy / Using Bootstrap
    • URL, for downloading / Using Bootstrap
    • about / But they all look the same!
    • lightweight alternatives / Lightweight alternatives

C

  • caching, backend performance
    • cached session backend / Cached session backend
    • caching frameworks / Caching frameworks
    • caching patterns / Caching patterns
  • Captain Temper /
  • Celery
    • working with / Working with Celery
    • working / How Celery works
    • best practices / Celery best practices
    • failure, handling / Handling failure
    • idempotent tasks / Idempotent tasks
    • writing, avoid to shared or global state / Avoid writing to shared or global state
    • passing complex objects, avoid to tasks / Avoid passing complex objects to tasks
  • class-based generic views
    • about / Class-based generic views
    • versus class-based views / Class-Based Views are not always Class-Based Generic Views
  • class-based views / Views got classier
  • classic web-scraper
    • example / The classic web-scraper example
    • synchronous web-scraping / Synchronous web-scraping
    • asynchronous web-scraping / Asynchronous web-scraping
  • Clickjacking
    • about / Clickjacking
    • Django, need for / How Django helps
  • code
    • jumping / Jumping around the code
  • code base / Understanding the code base
    • about / Understanding the code base
    • big picture, creating / Creating the big picture
    • PyGraphviz, installation / PyGraphviz installation and usage
    • PyGraphviz, usage / PyGraphviz installation and usage
  • code coverage / Learning more about testing
  • concurrency / Concurrency is not parallelism
  • content delivery network (CDN) / Frontend performance
  • context enhancers, view patterns
    • issue details / Problem details
    • solution details / Solution details
  • cross-site request forgery (CSRF) / Understanding CSRF
  • Cross-site request forgery (CSRF)
    • about / Why Django?, Cross-site request forgery
    • Django, need for / How Django helps
    • Django, avoiding / Where Django might not help
  • Cross-site scripting (XSS)
    • about / Why Django?, Cross-site scripting
    • cookies, valuable / Why are your cookies valuable?
    • Django, need for / How Django helps
    • Django, avoiding / Where Django might not help
  • CRUD views, form patterns
    • issue details / Problem details
    • solution details / Solution details
  • custom model managers, retrieval patterns
    • issue details / Problem details
    • solution details / Solution details
    • set operations, on QuerySets / Set operations on QuerySets
    • multiple QuerySets, chaining / Chaining multiple QuerySets

D

  • database
    • updating, without race conditions / Database updates without race conditions
  • debugging
    • about / Debugging
    • Django debug page / Django debug page
  • decorators / Decorators
  • department store URLs / Department store URLs
  • deployment tools
    • about / Deployment tools
    • fabric / Fabric
    • configuration management / Configuration management
  • development environment, Django
    • Python virtual environment / Best practices before starting a project
    • version control / Best practices before starting a project
    • project template, selecting / Best practices before starting a project
    • deployment pipeline / Best practices before starting a project
  • Django
    • need for / Why Django?
    • URL / Why Django?
    • about / The story of Django, Django keeps getting better
    • framework / A framework is born
    • module, removing / Removing the magic
    • working / How does Django work?
    • requisites, obtaining / How to gather requirements?
    • application, designing / Designing the application
    • project, dividing into apps / Dividing a project into apps
    • reuse / Reuse or roll-your-own?
    • app sandbox / My app sandbox
    • packages / Which packages made it?
    • best practices / Best practices before starting a project
    • React based SPA and Django REST API backend / React.js, Vue.js, and other view replacements
    • React based SPA and Django API endpoints / React.js, Vue.js, and other view replacements
    • forms in / Forms in Django
  • Django Channels
    • entering / Entering Channels
    • notifications, listening with WebSockets / Listening to notifications with WebSockets
    • Celery, differences / Differences from Celery
  • DjangoCons / Django keeps getting better
  • Django debug page
    • exception details / Django debug page
    • exception location / Django debug page
    • traceback / Django debug page
    • request information / Django debug page
    • about / A better debug page
  • Django Debug Toolbar / The Django Debug Toolbar
  • Django Rest framework (DRF)
    • about / Django Rest framework
    • Public Posts API, improving / Improving the Public Posts API
    • IDs, hiding / Hiding the IDs
  • Django Template Language (DTL)
    • features / Understanding Django's template language features
    • about / Understanding Django's template language features
    • variables / Variables
    • attributes / Attributes
    • filters / Filters
    • philosophy / Philosophy – don't invent a programming language
  • Django templates
    • debugging / Debugging Django templates
  • Django version
    • about / Which Django Version to use
    • feature release / Which Django Version to use
    • long-term support (LTS) release / Which Django Version to use
    • patch release / Which Django Version to use
    • finding / Finding the Django Version
    • virtual environment, activating / Activating the virtual environment
  • Docker
    • about / Virtual machines or Docker
    • microservices / Microservices
  • Dockerfile / Virtual machines or Docker
  • Don't Repeat Yourself (DRY) / Python Zen and Django's design philosophy, Designing the application
  • dynamic form generation, form patterns
    • issue details / Problem details
    • solution details / Solution details

E

  • Ellington CMS / A framework is born
  • endpoint callback pattern
    • about / Endpoint callback pattern
    • publish-subscribe pattern / Publish-subscribe pattern
    • polling pattern / Polling pattern
  • Entity-relationship model (ER-model) / The model hunt

F

  • fabric, deployment tools
    • deployment steps / Typical deployment steps
  • feature flags, admin
    • issue details / Problem details
    • solution details / Solution details
    • trails / Solution details
    • A/B testing / Solution details
    • performance testing / Solution details
    • limit externalities / Solution details
  • form patterns
    • about / Form patterns
    • dynamic form generation / Pattern – dynamic form generation
    • user-based forms / Pattern – user-based forms
    • multiple form actions, handling in view / Pattern – multiple form actions per view
    • CRUD views / Pattern – CRUD views
  • form processing
    • with class-based views / Form processing with class-based views
  • forms
    • working / How forms work
    • empty form / How forms work
    • filled form / How forms work
    • submitted form, with errors / How forms work
    • submitted form without errors / How forms work
    • in Django / Forms in Django
    • data cleaning / Why does data need cleaning?
    • displaying / Displaying forms
    • crisp / Time to be crisp
  • Fowler's patterns
    • about / Fowler's patterns
    • Domain logic patterns / Fowler's patterns
    • data source architectural patterns / Fowler's patterns
    • object-relational behavioral patterns / Fowler's patterns
    • object-relational structural patterns / Fowler's patterns
    • object-relational metadata mapping patterns / Fowler's patterns
    • web presentation patterns / Fowler's patterns
    • distribution patterns / Fowler's patterns
    • offline concurrency patterns / Fowler's patterns
    • session state patterns / Fowler's patterns
    • base patterns / Fowler's patterns
  • frontend performance
    • cache infinitely / Frontend performance
    • static asset manager / Frontend performance
  • full rewrite / Incremental change or a full rewrite?
  • Function as a Service (FaaS) / Serverless

G

  • Gang of Four (GoF) / Gang of four patterns
  • global interpreter lock (GIL) / Concurrency is not parallelism
  • Graphite / Monitoring
  • Gunicorn/Django container / Microservices

H

  • Hierarchical model-view-controller (HMVC) / Are there more patterns?
  • hosting
    • about / Hosting
    • Platform as a Service (PaaS) / Platform as a service
    • virtual private server (VPS) / Virtual private servers
    • serverless / Serverless
    • approaches / Other hosting approaches
  • HTML mockups / HTML mockups
  • human browsable interface, API pattern
    • issue details / Problem details
    • solution details / Solution details

I

  • incremental change / Incremental change or a full rewrite?
  • infinite scrolling, API pattern
    • issue details / Problem details
    • solution details / Solution details

J

  • Jinja2
    • about / Jinja2
    • familiarity / Jinja2
    • whitespace control / Jinja2
    • customizability / Jinja2
    • performance / Jinja2
    • autoescape / Jinja2

L

  • Law of Demeter (LoD) / Solution details
  • legacy database integration / Legacy database integration
  • logging / Logging
  • loose coupling / Python Zen and Django's design philosophy

M

  • Method Resolution Order (MRO) / Order of mixins
  • migrations / Migrations
  • mocking / Mocking
  • Model-Template-View (MTV) / Is Django MVC?
  • Model-View-Controller (MVC) / Is Django MVC?, M is bigger than V and C
  • Model-view-presenter (MVP) / Are there more patterns?
  • model hunt / The model hunt
  • model mixins / Model mixins
  • model mixins, structural patterns
    • issue details / Problem details
  • models
    • enhancing, for admin / Enhancing models for the admin
  • models.py file
    • splitting, into multiple files / Splitting models.py into multiple files
  • Model View ViewModel (MVVM) / Are there more patterns?
  • monitoring / Monitoring
  • multiple form actions, form pattern
    • issue details / Problem details
    • solution details / Solution details

N

  • Nginx container / Microservices
  • normal forms / Three steps of normalization
  • normalized models, structural patterns
    • issue details /
    • solution details / Solution details

O

  • object-relational mapping (ORM) / Performance and denormalization
  • Origin / Second normal form (2NF)
  • other debuggers / Other debuggers
  • other view replacements / React.js, Vue.js, and other view replacements

P

  • packages, Django
    • authentication / Which packages made it?
    • accounts / Which packages made it?
    • posts / Which packages made it?
  • parallelism / Concurrency is not parallelism
  • pattern
    • about / What is a pattern?, Are there more patterns?, Patterns in this book
    • Gang of Four (GoF) / Gang of four patterns
    • creational pattern / Gang of four patterns
    • structural pattern / Gang of four patterns
    • behavioral pattern / Gang of four patterns
    • Django, as MVC framework / Is Django MVC?
    • Fowler's patterns / Fowler's patterns
    • criticism of / Criticism of patterns
    • usage / How to use patterns
    • Python Zen / Python Zen and Django's design philosophy
    • Django's design philosophy / Python Zen and Django's design philosophy
  • Pattern-oriented software architecture (POSA) / Are there more patterns?
  • pattern name / Patterns in this book
  • performance
    • improving / Improving Performance
    • frontend performance / Frontend performance
    • backend performance / Backend performance
  • PHP / Where are the files? This is not PHP
  • plain old Python objects (POPOs) / Solution details
  • Platform as a Service (PaaS) / Platform as a service
  • post/redirect/get (PRG) pattern / Form processing with class-based views
  • PostgreSQL container / Microservices
  • print function / The print function
  • production environment
    • about / The production environment
    • web stack, selecting / Choosing a web stack
    • stack components / Components of a stack
  • projects / Dividing a project into apps
  • proofing
    • about / Future proofing
    • Django deprectations / Future proofing
    • code reviews / Future proofing
    • increase code coverage / Future proofing
    • type hinting / Future proofing
    • configuration management / Future proofing
  • property field, retrieval patterns
    • issue details / Problem details
    • solution details / Solution details
  • prototyping / My app sandbox
  • Python 3
    • features / Why Python 3?
  • Python debugger pdb / The Python debugger pdb

R

  • Rackspace / Other hosting approaches
  • React
    • React based SPA and Django REST API backend / React.js, Vue.js, and other view replacements
    • React based SPA and Django API endpoints / React.js, Vue.js, and other view replacements
  • React.js / React.js, Vue.js, and other view replacements
  • regular expression URL pattern syntax / Regular expression URL pattern syntax, Can the simplified syntax replace regular expressions?
  • Representational state transfer (REST) / RESTful URLs
  • REST architectural
    • resources / RESTful API
    • request operations / RESTful API
    • error codes / RESTful API
    • hypermedia / RESTful API
  • RESTful API
    • about / RESTful API
    • design / API design
    • versioning / Versioning
  • RESTful system
    • client-server / RESTful API
    • stateless / RESTful API
    • cacheable / RESTful API
    • layered system / RESTful API
    • code on demand / RESTful API
    • uniform interface / RESTful API
  • retrieval patterns
    • about / Retrieval patterns
    • property field / Pattern — property field
    • custom model managers / Pattern — custom model managers
  • rich-text editor
    • adding, for WYSIWYG editing / Adding a rich-text editor for WYSIWYG editing

S

  • security checklist / A handy security checklist
  • service objects, structural patterns
    • issue details / Problem details
    • solution details / Solution details
  • services, view patterns
    • issue details / Problem details
    • solution details / Solution details
  • session hijacking / Why are your cookies valuable?
  • shell injection
    • about / Shell injection
    • Django, used / How Django helps
    • web attacks / And the web attacks are unending
  • Single Page Application (SPA) / React.js, Vue.js, and other view replacements
  • single point of failure (SPOF) / The production environment
  • solution details, active link
    • template-only solution / A template-only solution
    • custom tags / Custom tags
  • solution details, multiple form actions
    • separate views, for separate actions / Separate views for separate actions
    • view, for separate actions / Same view for separate actions
  • solution details, normalized models
    • normalization / Three steps of normalization
    • first normal form (1NF) /
    • second normal form (2NF) / Second normal form (2NF)
    • third normal form (3NF) / Third normal form (3NF)
    • Django models / Django models
    • denormalization / Performance and denormalization
    • performance / Performance and denormalization
    • normalization, limits / Should we always normalize?
  • solution details, property field
    • cached properties / Cached properties
  • solution details, user profiles
    • signals / Signals
    • admin / Admin
    • multiple profile types / Multiple profile types
  • SQL injection
    • about / SQL injection
    • Django, need for / How Django helps
    • Django, avoiding / Where Django might not help
  • state attributes, form
    • is_bound / Forms in Django
  • stock views / Class-based generic views
  • structural patterns
    • about / Structural patterns
    • normalized models / Patterns — normalized models
    • model mixins / Pattern — model mixins
    • user profiles / Pattern — user profiles
    • service objects / Pattern – service objects
  • SuperBook
    • about / Are you a storyteller?, SuperBook – your mission, should you choose to accept it
    • Python 3, features / Why Python 3?
    • Django version, using / Which Django Version to use
    • project, starting / Starting the project
  • superhero intelligence and monitoring (SHIM) / M is bigger than V and C
  • synchronous scraper / Asynchronous web-scraping
  • synchronous web-scraping / Synchronous web-scraping
  • Syntactically awesome stylesheets (Sass) / Frontend performance

T

  • tags / Tags
  • template inheritance tree, template patterns
    • issue details / Problem details
    • solution details / Solution details
  • template layer / React.js, Vue.js, and other view replacements
  • template patterns
    • about / Template patterns
    • template inheritance tree / Pattern — template inheritance tree
    • active link / Pattern — the active link
  • templates
    • organizing / Organizing templates
    • working / How templates work
  • Test-driven Development (TDD) / Designing the application, TDD
  • test case
    • writing / Writing a test case, Writing better test cases
    • assert method / The assert method
    • don'ts / Writing better test cases
  • test factories
    • about / Pattern – Test fixtures and factories
    • issue details / Problem details, Solution details
    • solution details / Solution details
  • test fixtures
    • about / Pattern – Test fixtures and factories
    • issue details / Problem details
    • solution details / Solution details
  • testing
    • learning / Learning more about testing
  • tests
    • writing / Writing tests before making any changes, Why write tests?
    • writing, process / Step-by-step process to writing tests
  • thundering herds / Handling failure
  • tight cohesion / Python Zen and Django's design philosophy

U

  • Uniform Resource Identifiers (URIs) / URL anatomy, RESTful API
  • URL anatomy
    • about / URL anatomy
    • urls.py / What happens in urls.py?
    • URL pattern syntax, simplified / Simplified URL pattern syntax
    • regular expression URL pattern syntax / Regular expression URL pattern syntax
    • names and namespaces / Names and namespaces
    • pattern order / Pattern order
    • URL pattern styles / URL pattern styles
  • URL pattern styles
    • about / URL pattern styles
    • department store URLs / Department store URLs
    • RESTful URLs / RESTful URLs
  • URLs
    • designing / Designing URLs
  • urls.py
    • starting / Starting with urls.py
  • user-based forms, form pattern
    • issue details / Problem details
    • solution details / Solution details
  • user profiles, structural patterns
    • issue details / Problem details
    • solution details / Solution details

V

  • versioning, RESTful API
    • URI versioning / Versioning
    • query string versioning / Versioning
    • custom header versioning / Versioning
    • media type versioning / Versioning
  • view
    • about / A view from the top
    • class-based views / Views got classier
  • view mixins
    • about / View mixins
    • order of mixins / Order of mixins
  • view patterns
    • about / View patterns
    • access controlled views / Pattern — access controlled views
    • context enhancers / Pattern — context enhancers
    • services / Pattern – services
  • virtual environment
    • activating / Activating the virtual environment
  • virtual machines / Virtual machines or Docker
  • virtual private server (VPS) / Virtual private servers
  • Vue.js / React.js, Vue.js, and other view replacements

W

  • WebHook / Endpoint callback pattern
  • Web Server Gateway Interface (WSGI) / How does Django work?
lock icon The rest of the chapter is locked
arrow left Previous Section
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}