Adam Johnson Profile Banner
Adam Johnson Profile
Adam Johnson

@AdamChainz

Followers
11,458
Following
766
Media
938
Statuses
10,663

🦄 @djangoproject technical board member 🍕 @djangolondon ✍ - Boost Your {Django,Git} DX, Speed Up Your Django Tests ♂ He/him

London / Lisbon
Joined June 2012
Don't wanna be here? Send us removal request.
Explore trending content on Musk Viewer
Pinned Tweet
@AdamChainz
Adam Johnson
8 months
🚀 I have just released a major update to my 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.
4
7
80
@AdamChainz
Adam Johnson
1 year
Software Engineering at Google is a great read, and available for free online. I just cited this section on Logic in Tests whilst reviewing a PR:
Tweet media one
9
144
1K
@AdamChainz
Adam Johnson
3 years
22/2/22 Just Married
Tweet media one
113
4
513
@AdamChainz
Adam Johnson
3 years
Django applications are used to run Antarctic expeditions, energy distribution, logistics chains, and the World Food Program. The JPEG sharing site Instagram is cool but there are so many more uses!
17
60
391
@AdamChainz
Adam Johnson
2 years
friends don't let friends name their modules "utils"
48
41
385
@AdamChainz
Adam Johnson
3 years
🧵 Django 4.0’s five headline features...
7
95
340
@AdamChainz
Adam Johnson
2 years
Pleased to announce our son was born alive and healthy two weeks ago ❤️
51
2
337
@AdamChainz
Adam Johnson
3 years
🐎 Python’s Django template benchmark Python 3.10 is ~10% faster than Python 3.9 Python 3.11 (alpha!) is then ~15% faster than Python 3.10 🚀🚀🚀
Tweet media one
9
60
292
@AdamChainz
Adam Johnson
3 years
STOP USING DJANGO
Tweet media one
18
56
272
@AdamChainz
Adam Johnson
3 years
Our baby Lily Marques Johnson was born asleep 16 July. RIP. ❤️ We are devastated and I’ll be taking a break from everything for a while.
123
0
237
@AdamChainz
Adam Johnson
3 years
Tweet media one
15
35
230
@AdamChainz
Adam Johnson
3 years
🎨 Just got the cover image back from my illustrator... I asked for a “cybernetically enhanced pegasus”, and she delivered... what do you think?
Tweet media one
23
15
231
@AdamChainz
Adam Johnson
1 year
🕺 From #Python 3.13, virtual environments created by `venv` will come with a Git ignore file, thanks to @brettsky ’s PR merged yesterday. There’ll be no need to add `.venv` (or whatever) to your `.gitignore` file then.
4
34
227
@AdamChainz
Adam Johnson
3 years
Yesterday I updated my open source projects so that successive pushes to a PR cancel prior CI runs. Saves some time and processing power. I found the "how to" kinda hidden in the docs:
Tweet media one
10
19
225
@AdamChainz
Adam Johnson
2 years
✨The "where in the line" error message highlighting in Python 3.11 is awesome ✨ Thanks @pyblogsal @isidentical & Ammar Askar 👏
Tweet media one
3
26
216
@AdamChainz
Adam Johnson
10 months
🥳 The open source #Python projects I maintain now use pyproject.toml instead of setup.cfg!
Tweet media one
6
9
211
@AdamChainz
Adam Johnson
3 years
🥒 Python’s pickle can execute arbitrary code. If an attacker can get a pickle into your system, they can do anything they like! But how could they?
7
30
192
@AdamChainz
Adam Johnson
2 years
🎨 Did you know? From Django 4.1, code generated by Django (startproject, makemigrations, etc.) will be formatted by Black - just like the Django code base.
8
16
184
@AdamChainz
Adam Johnson
3 years
Wow Django’s Github stars are growing pretty linearly... no sign of stopping
Tweet media one
9
20
171
@AdamChainz
Adam Johnson
2 years
🧐 If you need to generate HTML within Python in Django, use its format_html function:
Tweet media one
5
33
164
@AdamChainz
Adam Johnson
3 years
📖🚀 It’s out! 🚀📖
14
31
164
@AdamChainz
Adam Johnson
3 years
Very exciting. Django will be adopting Black in the new year, as DEP 8 declared we will use the first stable release.
@llanga
Łukasz Langa
3 years
Version 21.10b0 of Black, your friendly #Python auto-formatter, is out now! 🖤 The biggest news is that thanks to @pradyunsg and @jelleszijlstra we adopted a stability policy that will go into effect starting with the first stable release in Jan 2022. 🤯
2
26
172
3
14
158
@AdamChainz
Adam Johnson
4 years
Use Django
15
16
157
@AdamChainz
Adam Johnson
2 years
friends don't let friends 'sudo pip install'
Tweet media one
7
17
157
@AdamChainz
Adam Johnson
3 years
✍️ Did you know Python has a built-in way to (kind-of) make an immutable dict? I only learnt about it recently, here’s my short writeup:
8
27
162
@AdamChainz
Adam Johnson
3 years
🎺📦 New package: django-browser-reload 📦🎺 It does what it says on the tin: in development it autmoatically refreshes your site when you make a change to a template or code. No more pounding “refresh”!
10
27
153
@AdamChainz
Adam Johnson
3 years
A myriad of Django Youtubers for you to check out this Friday 🧵
8
37
152
@AdamChainz
Adam Johnson
1 year
The best Django URL structure
Tweet media one
13
17
151
@AdamChainz
Adam Johnson
2 years
🧪 Django’s isolate_apps test tool allows you to create temporary model classes. Useful for testing model checks, decorators, etc.
Tweet media one
4
17
145
@AdamChainz
Adam Johnson
2 years
Yup, that printed faster
Tweet media one
4
0
144
@AdamChainz
Adam Johnson
2 years
🆙 Happy Sunday. I've just updated a bunch of my packages to support Django 4.1 (which is in Alpha) and Python 3.11 (which is in beta): * django-auto-prefetch * django-browser-reload * django-cors-headers * django-htmx * django-linear-migrations * django-mysql ...
6
21
145
@AdamChainz
Adam Johnson
2 years
Django
14
10
133
@AdamChainz
Adam Johnson
2 years
👀 The current version of Django is 4.0.4... luckily 'pip install' finds it!
4
11
137
@AdamChainz
Adam Johnson
2 years
@willmcgugan My pacakage patchy lets you live-patch functions to change what they do. Useful for applying small changes to third party dependencies without forking.
Tweet media one
8
9
125
@AdamChainz
Adam Johnson
4 years
✍️ ”I'm delighted to announce my new e-book, coming May 18... Speed Up Your Django Tests! It's a practical guide to making your #Django project's tests faster...”
13
32
120
@AdamChainz
Adam Johnson
4 years
Django is built with Python. is built with Django.
6
19
118
@AdamChainz
Adam Johnson
3 years
🎉 My new book Boost Your Django DX will be released January 10th 🎉 Pre-order now for $35 instead of $39, saving 10.2564%.
6
25
109
@AdamChainz
Adam Johnson
3 years
@activefog @thefinaldownco @PrasoonPratham The problem is using the shared, predictable random instance. If some other piece of code (e.g. a library you installed), calls random.seed(0), then your passwords will be the same every time.
1
1
109
@AdamChainz
Adam Johnson
2 years
✍️ New post covering profiling your #Django project’s startup time, and techniques to improve it. It’s a big one, enjoy!
8
19
107
@AdamChainz
Adam Johnson
3 years
📦 New package: django-minify-html 📦 This provides a Django middleware for running minify-html, the “extremely fast and smart HTML + JS + CSS minifier”. It minifies HTML, and any inline JS and CSS, with little overhead.
5
16
106
@AdamChainz
Adam Johnson
3 years
✋ printf("...") 👉 print(f"...")
Tweet media one
6
10
106
@AdamChainz
Adam Johnson
11 months
hard #Git truth
Tweet media one
8
16
104
@AdamChainz
Adam Johnson
3 years
Achievement unlocked, thx @github
Tweet media one
5
4
103
@AdamChainz
Adam Johnson
4 years
🎉 “We are happy to tell you that your submission "How to Hack a Django Website" has been accepted for @DjangoConEurope 2020.” ...watch out 🕵️‍♂️
10
3
105
@AdamChainz
Adam Johnson
2 years
The journey of a thousand lines begins with a single import
6
9
100
@AdamChainz
Adam Johnson
3 years
✨Just released django-rich 1.2.0 with a new Rich-based test runner thanks to @David_Smith86 ! ✨ This gives Django’s test framework a nice lick of paint and useful features like expanded tracebacks with locals and clickable source links. Check it out:
Tweet media one
2
16
99
@AdamChainz
Adam Johnson
3 years
🦖 Build your own Jurassic Park in Python with \N to reference a Unicode character by name:
Tweet media one
2
18
98
@AdamChainz
Adam Johnson
3 years
✍️ Tips for debugging with print() in Python
9
32
100
@AdamChainz
Adam Johnson
2 years
✍️ This afternoon I've written a bunch of TypedDict types such as the below to add type hints to some existing code, similar to the below.
Tweet media one
2
9
102
@AdamChainz
Adam Johnson
3 years
✍️ When I started writing type hints, I was a little confused about what to do with Python’s variable argument operators, * and ** (often called *args and **kwargs). Here’s what I figured out.
2
26
95
@AdamChainz
Adam Johnson
3 years
Django has the original Meta
1
7
98
@AdamChainz
Adam Johnson
3 years
🧵 Some Django accounts to follow!
4
13
98
@AdamChainz
Adam Johnson
2 years
🎉 Porto here we come!
Tweet media one
7
1
96
@AdamChainz
Adam Johnson
2 years
📚 Your regular reminder to check the Django documentation page “Database Access Optimization” to improve your usage of the ORM !
2
17
95
@AdamChainz
Adam Johnson
3 years
✍️ I made a new tool to automatically upgrade Django projects, here’s the intro post!
7
26
94
@AdamChainz
Adam Johnson
11 months
🥳 Boost Your Git DX is out! 🥳 📕 353 pages across 18 chapters on improving your #Git command line development experience. 💁 It covers the best tools, techniques, tips, tricks, and tactical tidbits that I’ve encountered in 11 years of using Git.
Tweet media one
6
29
95
@AdamChainz
Adam Johnson
4 years
🤖 Here's a simple view for serving a robots.txt from #Django . See my tutorial for how this works, an alternative implementation with a template, and tests:
Tweet media one
4
18
92
@AdamChainz
Adam Johnson
1 year
POV: standing desk + split keyboard + sling + baby
Tweet media one
14
1
92
@AdamChainz
Adam Johnson
3 years
Django REST Framework is now using @pre_commit !
1
7
92
@AdamChainz
Adam Johnson
3 years
Did you ever hit the PyPI 404 page... and scroll down? 💁‍♂️🧀
6
18
94
@AdamChainz
Adam Johnson
4 years
✍️ Using the phrase "of course" is condescending when you're explaining something, as it implies the reader should have already figured this out. I've just made a PR to remove its usage from the #Django docs.
8
3
89
@AdamChainz
Adam Johnson
2 years
This talk was brilliant, it showed real world outcomes of moving from a JS rendered site to plain HTML
5
6
92
@AdamChainz
Adam Johnson
3 years
@activefog @thefinaldownco @PrasoonPratham Moreover the default seed is the current time. If I know the algorithm and that the hour the password was generated, I can just test, say, the first 100 passwords for each of the 3600 seconds in the last hour, which is ~10^5 options rather than ~10^63 as the code intends.
1
1
92
@AdamChainz
Adam Johnson
1 year
Django 5.0 “deluge” is in alpha, with the final release expected December 4th. Loads of new features in there!
7
16
90
@AdamChainz
Adam Johnson
9 months
In #Django 5.1, test client methods will have a new query_params parameter to simplify adding URL query parameters. Thanks to Tom Carrick for the PR, @carlton , David Sanders and @felixxm for reviewing, and everyone who participated in the forum discussion.
Tweet media one
6
8
90
@AdamChainz
Adam Johnson
9 months
Django 5.0 let’s gooooooooo!
@djangoproject
Django
9 months
Django 5.0 released
67
415
2K
1
5
90
@AdamChainz
Adam Johnson
3 years
✍️ I'm writing a new book of ways to improve your development workflow with Django. If you're interested in beta reading, sign up on this little form:
12
20
89
@AdamChainz
Adam Johnson
3 years
🧵 Some Django people to follow this friday
4
15
87
@AdamChainz
Adam Johnson
3 years
✍️ “I recently upgraded my client to PostgreSQL 13... I reindexed all tables after the upgrade to take advantage of this [new] deduplication and saw index storage savings of up to 90%.“
5
13
89
@AdamChainz
Adam Johnson
1 year
🚀 @MariuszFelisiak just merged the database-generated fields commit into the upcoming Django 5.0. Generated fields are computed by the database from other field values. They’re useful for shortening lookups, and even speeding them up if indexed.
4
11
89
@AdamChainz
Adam Johnson
3 years
🐍🧵 For custom classes, Python normally backs instances with a dictionary. But if you declare __slots__ on a Python class, it can use a more efficient representation, at the cost of disallowing arbitrary extra attributes.
Tweet media one
2
9
82
@AdamChainz
Adam Johnson
3 years
260 sales / $9,159 revenue for the new book so far. Thanks to everyone who preordered and bought 🙏🙏🙏
Tweet media one
4
1
87
@AdamChainz
Adam Johnson
2 years
🕰 If your project uses freezegun to mock datetime, move to my library time-machine to speed up your tests. It has a similar API but it's 100x faster, or more. It's O(1) rather than O(len(sys.modules)) !
4
19
85
@AdamChainz
Adam Johnson
1 year
🧹 Clean up old, not-running Docker resources with this one-liner: docker system prune --all --force --filter until=24h && docker volume prune --force This command can save you a lot of disk space, I just used it to reclaim 38GB!
3
14
88
@AdamChainz
Adam Johnson
3 years
oh no, I only know HTML and python
11
1
85
@AdamChainz
Adam Johnson
3 years
✍️ “The Boolean Trap” is a programming anti-pattern where a boolean argument switches behaviour, leading to confusion. In this post we’ll look at the trap in more detail, and several ways to avoid it in Python, with added safety from type hints.
7
12
84
@AdamChainz
Adam Johnson
2 years
✍️ New blog post on safely passing data to JavaScript in Django templates
8
22
81
@AdamChainz
Adam Johnson
2 years
I’m 0x21 today 🥳
34
0
82
@AdamChainz
Adam Johnson
2 years
🙌 Just passed 1,000 customers on @gumroad ! 😎
6
0
82
@AdamChainz
Adam Johnson
3 years
Normally I develop just against localhost, but sometimes you need a real hostname to trigger particular web features. You can use for this, e.g. redirects to localhost:8000 .
7
11
77
@AdamChainz
Adam Johnson
1 year
Can you spot the problem with this Django snippet? 🧵
Tweet media one
4
9
79
@AdamChainz
Adam Johnson
2 years
🔮 Useful new feature just committed, coming in Django 4.2: robust on_commit() callbacks on_commit(..., robust=True) will mean that if the callback fails, its exception is caught and logged, and other callbacks will also run. e.g. trying to send two types of notification:
Tweet media one
2
14
76
@AdamChainz
Adam Johnson
3 years
⏰ When I'm waiting for a GitHub Actions run to complete, I use watch + GitHub CLI to check it - e.g. earlier whilst my blog deployed:
Tweet media one
4
5
78
@AdamChainz
Adam Johnson
4 years
👏👏👏 Congratulations to fellow @djangolondon organizer @cagilulusahin for her first code contribution to Django core. It fixes something that's bothered me for a while - migrations altering columns when only Python-level metadata has changed.
9
10
77
@AdamChainz
Adam Johnson
5 years
Flight attendant: Is there a Dr. on this flight? Dad: *nudging me* that should've been you Me: Not now Dad Dad: Not looking for a Pythonista are they? Me: Dad, there’s an emergency Dad: Go and see if using "python -m pip install" instead of "pip install" will help
6
10
78
@AdamChainz
Adam Johnson
2 years
🚨 PyPI Phishing Attack 🚨 Two hours ago, I received the below email from a Mailchimp account - it's a phishing attack attempting to steal PyPI credentials. I happened to check my "spam" just now and find it.
Tweet media one
1
41
76
@AdamChainz
Adam Johnson
3 years
🚄 I've just made my site more performant. It now scores 100 on pagespeed insights, up from 96. Here’s the 5 changes I made 🧵
Tweet media one
4
13
77
@AdamChainz
Adam Johnson
3 years
This is great to wake up to. Thanks to all preorderers.
Tweet media one
3
1
75
@AdamChainz
Adam Johnson
3 years
#4 Built-in Redis cache backend @Redisinc is very popular with Django developers. Previously it was mainly used via the django-redis package, but now it’s built-in! Thanks to @Abbasidaniyal_ for contributing this as a Google of Summer of Code project.
Tweet media one
4
2
77
@AdamChainz
Adam Johnson
2 years
Yeah I made it @DjangoConEurope
Tweet media one
6
1
76
@AdamChainz
Adam Johnson
3 years
✍️ Python’s functools.partial is a great tool that I feel is underused. Here are a few ways I’ve used partial in Django projects.
6
15
75
@AdamChainz
Adam Johnson
11 months
♦️oh-my-zsh just got some new Git aliases! 🎋 gbm = git branch --move, to rename a branch ⏪ grhk = git reset --keep, to reset without throwing out uncommitted changes ⏪ grhs = git reset --soft, to reset without changing files, effectievly “undoing” commits ...
Tweet media one
5
5
72
@AdamChainz
Adam Johnson
3 years
Amazon Web Services recruiter: interested in applying? Me:
Tweet media one
3
1
73
@AdamChainz
Adam Johnson
1 year
Building a new #Django project, hit a Django bug within 30 minutes of working on it, searching reveals that I caused that bug 😅
5
0
75
@AdamChainz
Adam Johnson
3 years
✍️A post on using Python’s http.HTTPStatus enum to avoid having status codes as “magic numbers” in your Django project
4
10
69
@AdamChainz
Adam Johnson
3 years
Does this chapter have enough tools in it?
Tweet media one
17
2
74
@AdamChainz
Adam Johnson
3 years
👀 Can you spot the problem in this code? (Also possible with unittest’s self.assertRaises() method) 🧵
Tweet media one
8
12
71
@AdamChainz
Adam Johnson
3 years
Kevin is happy to see Django 4.0 available!
Tweet media one
@djangoproject
Django
3 years
Django 4.0 released
25
463
1K
5
0
71
@AdamChainz
Adam Johnson
10 months
I just wrote this proposal that #Django ’s third-party package tutorial recommend using a `django_` module prefix to prevent name collisions, such as the historical one between django-ratelimit and ratelimit. What do you think?
8
2
74