Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Adam Johnson

Rating No ratings yet

DX is a broadly applicable term. Many things can improve your development experience, from a smooth keyboard to a supportive team to humorous “Looks Good To Me” memes. But in this book, we’ll focus on tools and practices. This book is meant to serve as many situations as possible. We will primarily cover open source, cross-platform tools. We won’t look at any particulars of writing “normal” Django code. We’re working at the level above: improvements to the process, not the process itself. We will focus on Django projects instead of third-party packages published on PyPI. But packages overlap with projects, so most of the tools we’ll look at apply; there are others we won’t touch on. We’ll not cover anything specific to text editors, JavaScript frameworks, or production environments. These worlds are too varied to cover much ground in one book. But please do seek process improvements in these areas.

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A practical toolkit for Django developers who want to upgrade their workflow—covering everything from virtual environments and dependency management to debugging, terminal output, and editor configuration—this book is for anyone who spends more time fighting tooling than writing code. 【Book Arc】 - **Opening (~0%–10%)**: Defines the book's scope—focusing on tools and practices that improve the development process, not Django code itself. Sets expectations: open-source, cross-platform tools, and a project-centric (not package-centric) approach. - **Early (~10%–23%)**: Dives into virtual environments and dependency management. Covers venv vs. virtualenv, pip-compile for reproducible requirements, and strategies for scheduling upgrades (with specific release cadences for Python, Django, and PostgreSQL). - **Early (~23%–32%)**: Explores the Python shell, emphasizing IPython's superiority over the default. Covers practical commands like `-c` for one-liners, input history, and the `django-read-only` package for protecting production data during interactive sessions. - **Middle (~32%–48%)**: Focuses on debugging with pdb and ipdb. Demonstrates post-mortem debugging, stack navigation, and project-local `.pdbrc` files for shared aliases and imports. Also introduces Rich for beautiful terminal output and editorconfig for consistent formatting. - **Late (~48%–end)**: Covers documentation and settings. Recommends DevDocs and DuckDuckGo for faster lookups, wget for offline docs, and provides a comprehensive guide to structuring Django settings files with environment variables, pathlib, and avoiding common anti-patterns. 【Key Takeaways】 - **Virtual environments are the foundation of dependency hygiene** (Early): Use `.venv` as the directory name for automatic detection by tools like VS Code and PyCharm. Rerunning `activate` is safe and often necessary after installing new tools. - **pip-compile turns loose requirements into reproducible builds** (Early): Declare direct dependencies in `requirements.in`, and pip-compile generates a fully-pinned `requirements.txt` with transitive dependencies. It reuses existing versions unless you use `-U`, and drops packages no longer needed. - **Dependency upgrades need a schedule, not just a tool** (Early): Treat upgrades like washing dishes—regular hygiene beats occasional marathons. Medium teams should upgrade everything every two weeks or monthly; larger teams may go continuous. Schedule major component upgrades (Python, Django, PostgreSQL) separately on the team calendar. - **IPython transforms the Django shell experience** (Early): Django automatically prefers IPython when installed. Use `-c` for scriptable one-liners, leverage input history with `In`/`Out` and `_i<n>` shortcuts, and enable `%autoreload` to avoid restarting the shell after code changes. - **django-read-only protects production data during interactive sessions** (Early): Set `DJANGO_READ_ONLY=1` to block write queries in the shell, with an escape hatch via `enable_writes()` or the `temp_writes()` context manager. Configure it via shell config files or PaaS-specific environment variables. - **pdb's post-mortem debugging is a superpower** (Middle): When an uncaught exception occurs, pdb automatically enters post-mortem mode, pausing at the crash site. Use `u`/`d` to navigate the call stack and inspect variable values at each level—invaluable for tracing bugs. - **Project-local .pdbrc files standardize debugging across teams** (Middle): Add aliases and default imports (like `from django.utils import timezone as tz`) to a `.pdbrc` file in your repo root. These don't shadow debugged variables, and package imports belong here, not in your home directory file. - **EditorConfig prevents diff noise and formatting wars** (Middle): Configure `charset = utf-8`, `end_of_line = lf`, `indent_style = space`, `indent_size = 2`, `trim_trailing_whitespace = true`, and `insert_final_newline = true` to keep every file consistent and diffs clean. 【Reading Tips】 - **Skim the changelog and intro** (~0–10%): Understand the book's scope and what's been updated since the 2022 initial release—especially the removed "Disallow auto-named migrations" advice. - **Deep-read the dependency management chapter** (~10–23%): This is where the most actionable, time-saving advice lives. The pip-compile workflow and upgrade scheduling are worth implementing immediately. - **Practice the debugging examples** (~32–48%): Don't just read about pdb—run the pizza_party.py example yourself. The stack navigation and post-mortem debugging skills are best learned by doing. - **Use the settings chapter as a reference** (~48%+): The settings structure guidance (single file with env vars, grouping, pathlib) is a checklist to apply to your own project, not a narrative to read straight through. - **Skip the documentation chapter if you're already set** (~48%): The DevDocs and wget sections are useful for offline work, but the "bonus Django documentation sites" list is skimmable if you already know Classy Class-Based Views and similar resources. 【Coverage Limits】 The excerpts cover the book's first half in detail (virtual environments, dependencies, shell, debugging) and provide a table of contents for the second half (documentation, settings). Specific chapters on editors, testing tools, and other topics mentioned in the TOC are not covered in the provided material.
Page 7
o REST Framework . . . . . . . . . . . . . . . . . 229 10.3.5 Awesome Django . . . . . . . . . . . . . . . . . . . . . . . . . . 230 10.3.6 Django TV . . . ....
View in text
Excerpt 2
ge) # via -r requirements.in sqlparse==0.5.1 # via django 3. Uninstall the package from your virtual environment with plain Pip: $ python -m pip uninstall dj...
View in text
Excerpt 3
jango DX, Release 2024-11-18 (continued from previous page) Running 'cont' or 'step' will restart the program > /.../pizza_party.py(2)share_pizza() -> slices...
View in text
Excerpt 4
he toolbar: When open, click “Hide »” to close the toolbar. The toolbar comprises several panels, which are customizable. Each panel gathers its data during...
View in text
Excerpt 5
ode style is well-documented129 with examples and rationale. Here’s a summary: • Lines are wrapped at 88 characters. • Indentation is normalized to four spac...
View in text
Excerpt 6
r configuration, check out Biome’s migration guide192 too.) pre-commit hook Use the below pre-commit hook configuration. Find this file in resources.zip as f...
View in text
Excerpt 7
e to focus the search box and clear the latest search term. Press escape again to clear any restriction to a particular documentation source. This returns De...
View in text
Excerpt 8
over over the HTMLParser definition to reveal a pilcrow (¶). Click on the pilcrow, and the page highlights the definition and scrolls to it: Then, in the URL...
View in text
Tags
AI categories
PythondjangoBackend
Publisher: Adam Johnson
Publish Year: 2024
Language: English
Pages: 326
File Format: PDF
File Size: 21.7 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…