Boost Your Django DX update out now

Esther the enhanced equine across the stars.

I just released a major update to my 2021 book Boost Your Django DX. This update contains new content, a bunch of edits, and uses the latest versions of tools, including Python 3.12 and Django 5.0.

Boost Your Django DX contains many recommendations to improve your development experience (DX) while working on Django projects. It covers code quality tools (linters and formatters), virtual environments, models, migrations, settings, and even documentation. See below for the full updated table of contents.

The book has sold over one thousand copies, including some large team licenses. I hope this update extends its utility and helps even more developers work smarter.

This update is free for all who previously purchased the book, and I’ve sent an email out to notify readers. There’s a changelog in the first chapter with links to the changed sections, reproduced below.

As part of this update, I’m increasing the price from $39 to $42. This headline price is automatically discounted up to 60% to match local purchasing power in your country. There’s also a bundle deal with my new Git book, and team licenses are available.

Buy now on Gumroad

May you embrace the spirit of continuous improvement this year,

—Adam

Changelog

Table of contents

  1. Origin
    1. About this book
      • Read in any order
      • Example commands and resources
      • End-of-chapter feedback links
    2. Acknowledgements
    3. Changelog
  2. Documentation
    1. DevDocs: the free rapid documentation tool
      • Get started and set up Django’s docs
      • Perform a basic search
      • Search a single documentation source
      • Reset the search box
      • Visit the original documentation site
      • Download documentation sources for offline use
      • Useful documentation sources
      • More on DevDocs
    2. DuckDuckGo: a developer-friendly search engine
      • Access DuckDuckGo
      • Keyboard shortcuts
      • Bangs: shortcuts to other search pages
      • Instant Answers: expanded results on the first page
    3. Bonus Django documentation sites
      • Classy Class-Based Views
      • Classy Django Forms
      • Template Tags and Filters
      • Classy Django REST Framework
      • Awesome Django
    4. Wget: download any website
      • Install
      • How to download a website
      • Example: the Django REST Framework documentation
      • Read offline documentation with Python’s web server
      • An explanation of all the flags
    5. Miscellaneous tips and tricks
      • Python documentation
      • Django documentation
      • Read the Docs
      • Sphinx
  3. Virtual Environments and Dependencies
    1. On tools and choice
    2. Virtual environments
      • Create a virtual environment with venv
      • Avoid committing your virtual environment
      • Activate a virtual environment
      • Deactivate a virtual environment
      • Maybe use virtualenv instead of venv
    3. Pip and extra tools
      • Invoke Pip safely
      • The problems with pip freeze > requirements.txt
      • pip-compile: simple dependency management
      • Convert an existing requirements.txt file to pip-compile
      • Add a new dependency with pip-compile
      • Remove a dependency With pip-compile
      • Upgrade dependencies with pip-compile
      • pip-lock: keep all environments up to date
    4. Dependency management
      • Stick to a single set of dependencies (probably)
      • Pick new dependencies carefully
      • Set a dependency upgrade schedule
    5. Python’s Development Mode
      • Enable development mode
      • Check if development mode is enabled
      • When to use development mode
  4. Python Shell
    1. The shell command
      • Execute a string with -c
      • Execute a temporary file with -c 'import t'
    2. IPython: a superior Python shell
      • Install IPython
      • Get help with ? or ??
      • Advanced autocomplete with tab
      • Reuse results with the output history
      • Export and rerun code with the input history
      • Copy in code with multi-line paste and %cpaste
      • Iterate quickly with autoreload
      • Start IPython within your code with IPython.embed()
      • Improved debugging with IPython’s debugger
      • Use IPython’s debugger outside of IPython
      • Benchmark code with %timeit
    3. django-read-only: production data protection
  5. Development Server
    1. django-debug-toolbar: a development boon
      • Install and configure
      • Explore the toolbar
      • Find problematic database queries with the SQL panel
      • Trace non-HTML requests with the history panel
    2. django-browser-reload: automatically reload your browser in development
      • Reloads triggered by template changes
      • Reloads triggered by static asset changes
      • Reloads triggered by code changes
      • Installation
    3. Rich: beautiful terminal output
      • Server logs
      • Management commands
  6. Code Quality Tools
    1. EditorConfig: consistent text editing
    2. pre-commit: a code quality framework
      • What pre-commit is
      • Install pre-commit
      • Add a configuration file
      • Configuration structure
      • Pin language versions with default_language_version
      • Various ways to run hooks
      • Update hooks With pre-commit autoupdate
      • Run pre-commit in CI with pre-commit ci
      • Introduce a hook incrementally
    3. Black: the uncompromising code formatter
      • How Black formats code
      • Install and configure Black
      • blacken-docs: apply Black to documentation
    4. isort: sorted, grouped import statements
      • isort’s style
      • Install and configure isort
      • Add or remove imports from every file
    5. Flake8: an extensible linter
      • Install and configure Flake8
      • flake8-bugbear: extra checks for common problems
      • flake8-no-pep420: avoid package problems
      • Further plugins
  7. Further Code Quality Tools
    1. pyupgrade: upgrade to the latest Python syntax
      • Some example rewrites
      • Install and configure
    2. django-upgrade: upgrade to the latest Django features
      • Example rewrites
      • Install and configure
    3. pre-commit-hooks: general purpose checks
    4. reorder-python-imports: an alternative import sorter
      • One import per line
      • Rewrite old imports
    5. DjHTML: a template formatter
      • Example re-indentation
      • Install and configure
    6. Mypy: check your types
    7. Prettier: format your CSS, JavaScript, and more
      • Supported languages
      • Example JavaScript formatting
      • Example CSS formatting
      • Install and configure
      • Format more languages with plugins
    8. ESLint: the top JavaScript linter
      • Example lint errors
      • Install and configure
      • Ignore Prettier-induced issues with eslint-config-prettier
    9. ShellCheck: find bugs in your shell scripts
      • An example
      • Install
  8. Build Your Own Tools
    1. pre-commit’s virtual languages: rapid checks
      • Write a custom “fail” hook
      • Write a custom regular expression hook
    2. Flake8 plugin: custom source code checks
      • The Abstract Syntax Tree (AST)
      • Further AST exploration
      • Plugin structure
      • Make a plugin to ban lambda
      • Test your plugin
      • Further reading
    3. Write a custom tool
      • Replace Django documentation links
      • What pre-commit expects of tools
      • Make a tool
      • Example usage
      • Run the tool with pre-commit
      • Add tests
  9. Settings
    1. Structure your settings
      • Use a single settings file with environment variables
      • Load a .env file locally
      • Settings in tests
      • Group and sort settings
      • Order INSTALLED_APPS
      • Use pathlib for BASE_DIR
      • A settings file template
    2. Some settings patterns to avoid
      • Don’t read settings at import time
      • Avoid direct setting changes
      • Don’t import your project settings module
      • Avoid creating custom settings where module constants would do
      • Avoid creating dynamic module constants instead of settings
      • Name your custom settings well
      • Override complex settings correctly
    3. Test your settings file
      • Test your settings functions
      • Test your settings logic
  10. Models and Migrations
    1. Seed your database with a custom management command
      • Sample data approaches
      • Create a command
      • Test your command
    2. Factory Boy: easier data generation
      • Install and define factories
      • Invoke factories
      • Use factories in tests
      • Use factories in seed_database
      • Further features
    3. Migration safeguards
      • Test for pending migrations
      • django-linear-migrations: prevent merge migrations
  11. System Checks
    1. How system checks work
      • The basics
      • How to silence checks
      • The advantages of checks
    2. Write your own checks
      • How to write a check function
      • How to register a check function
      • Add a check for Python’s development mode
      • Add a check for model class names
    3. Test your checks
      • Test the development mode check
      • Test the model name check
    4. Further places that checks live
      • Model class checks
      • Model field checks
    5. django-version-checks: keep your environments in sync
      • Install and configure
      • Upgrading dependencies
  12. Terminus
    1. Further reading
    2. Thank you

Subscribe via RSS, Twitter, Mastodon, or email:

One summary email a week, no spam, I pinky promise.

Tags: