Django Design Patterns and Best Practices

Easily build maintainable websites with powerful and relevant Django design patterns

Django Design Patterns and Best Practices

This ebook is included in a Mapt subscription
Arun Ravindran

1 customer reviews
Easily build maintainable websites with powerful and relevant Django design patterns
$10.00
$44.99
RRP $35.99
RRP $44.99
eBook
Print + eBook
Preview in Mapt

Book Details

ISBN 139781783986644
Paperback222 pages

Book Description

Learning how to write better Django code to build more maintainable websites either takes a lot of experience or familiarity with various design patterns. Filled with several idiomatic Django patterns, Django Design Patterns and Best Practices accelerates your journey into the world of web development.

Discover a set of common design problems, each tackling aspects of Django including model design and Views, and learn several recommended solutions with useful code examples and illustrations. You'll also get to grips with the current best practices in the latest versions of Django and Python. Creating a successful web application involves much more than Django, so advanced topics including REST, testing, debugging, security, and deployment are also explored in detail.

Table of Contents

Chapter 1: Django and Patterns
Why Django?
The story of Django
What is a Pattern?
Patterns in this book
Best practices
Summary
Chapter 2: Application Design
How to gather requirements
Are you a story teller?
HTML mockups
Designing the application
Before starting the project
SuperBook – your mission, should you choose to accept it
Summary
Chapter 3: Models
M is bigger than V and C
The model hunt
Structural patterns
Retrieval patterns
Migrations
Summary
Chapter 4: Views and URLs
A view from the top
Class-based generic views
View mixins
Decorators
View patterns
Designing URLs
Summary
Chapter 5: Templates
Understanding Django's template language features
Organizing templates
Using Bootstrap
Template patterns
Summary
Chapter 6: Admin Interface
Using the admin interface
Enhancing models for the admin
Admin interface customizations
Protecting the admin
Summary
Chapter 7: Forms
How forms work
Displaying forms
Understanding CSRF
Form processing with Class-based views
Form patterns
Summary
Chapter 8: Dealing with Legacy Code
Finding the Django version
Where are the files? This is not PHP
Starting with urls.py
Jumping around the code
Understanding the code base
Incremental change or a full rewrite?
Write tests before making any changes
Legacy databases
Summary
Chapter 9: Testing and Debugging
Why write tests?
Test-driven development
Writing a test case
Mocking
Pattern – test fixtures and factories
Learning more about testing
Debugging
The print function
Logging
The Django Debug Toolbar
The Python debugger pdb
Other debuggers
Debugging Django templates
Summary
Chapter 10: Security
Cross-site scripting (XSS)
A handy security checklist
Summary
Chapter 11: Production-ready
Production environment
Hosting
Deployment tools
Monitoring
Performance
Summary

What You Will Learn

  • Understand common design patterns that can help you write better Django code
  • Discover the latest best practices and idioms in this rapidly evolving framework
  • Deep dive into various aspects of Django from Models and Views to testing and deployment
  • Get to grips with difficult topics such as dealing with legacy code and debugging
  • Familiarize yourself with the various nuances of web development such as browser attacks and databases
  • Reduce the maintenance burden with well-tested, cleaner code
  • Show your work to the world by learning about hosting, deploying, and securing your Django projects

Authors

Table of Contents

Chapter 1: Django and Patterns
Why Django?
The story of Django
What is a Pattern?
Patterns in this book
Best practices
Summary
Chapter 2: Application Design
How to gather requirements
Are you a story teller?
HTML mockups
Designing the application
Before starting the project
SuperBook – your mission, should you choose to accept it
Summary
Chapter 3: Models
M is bigger than V and C
The model hunt
Structural patterns
Retrieval patterns
Migrations
Summary
Chapter 4: Views and URLs
A view from the top
Class-based generic views
View mixins
Decorators
View patterns
Designing URLs
Summary
Chapter 5: Templates
Understanding Django's template language features
Organizing templates
Using Bootstrap
Template patterns
Summary
Chapter 6: Admin Interface
Using the admin interface
Enhancing models for the admin
Admin interface customizations
Protecting the admin
Summary
Chapter 7: Forms
How forms work
Displaying forms
Understanding CSRF
Form processing with Class-based views
Form patterns
Summary
Chapter 8: Dealing with Legacy Code
Finding the Django version
Where are the files? This is not PHP
Starting with urls.py
Jumping around the code
Understanding the code base
Incremental change or a full rewrite?
Write tests before making any changes
Legacy databases
Summary
Chapter 9: Testing and Debugging
Why write tests?
Test-driven development
Writing a test case
Mocking
Pattern – test fixtures and factories
Learning more about testing
Debugging
The print function
Logging
The Django Debug Toolbar
The Python debugger pdb
Other debuggers
Debugging Django templates
Summary
Chapter 10: Security
Cross-site scripting (XSS)
A handy security checklist
Summary
Chapter 11: Production-ready
Production environment
Hosting
Deployment tools
Monitoring
Performance
Summary

Book Details

ISBN 139781783986644
Paperback222 pages
Read More
From 1 reviews

Read More Reviews