Blog Info | Adam Johnson |
---|---|
Blog website | Link |
Jan. 9, 2025 » Adam Johnson » [Archived Version]
JavaScript’s import statement lets module scripts import objects from other scripts. For example, you can define a script as a module in HTML: <script type=module src="/static/js/index.js"></script> Then that file can import from another, like: import { BigBlueButton } from "/static/js/lib/buttons.js"; // ... This …
Read MoreJan. 8, 2025 » Adam Johnson » [Archived Version]
You might see this message when running pytest on your Django project: $ pytest ... Exception ignored in: <django.core.management.base.OutputWrapper object at 0x108576170> Traceback (most recent call last): File "/.../django/core/management/base.py", line 171, in flush self._out.flush() ValueError: I/O operation on closed file. The …
Read MoreDec. 27, 2024 » Adam Johnson » [Archived Version]
Previously, I covered using 1/0 to crash Python within minimal typing, useful to quickly answer questions like “does the code even get here?”. Recently, I wanted to do the same in Django templates, to trace if a given template was even being rendered, and under which code paths. It …
Read MoreDec. 18, 2024 » Adam Johnson » [Archived Version]
Yesterday, I held another quiz at the December edition of Django London. The quiz is a regular tradition at our meetup, a way of having a more relaxed event in December and giving away some nice prizes. This was the sixth quiz that I’ve presented, and the seventh overall …
Read MoreDec. 5, 2024 » Adam Johnson » [Archived Version]
Here’s another technique for using pdb within Django. I will add this to the new debugging chapter of Boost Your Django DX in a future update. When debugging Django code, you might need to start with a given SQL query and work backwards to find the code that triggered …
Read MoreNov. 28, 2024 » Adam Johnson » [Archived Version]
In my recent Boost Your Django DX update, I added a new chapter on debuggers. Here’s an extra technique I didn’t finish in time for the update, but I will include it in the next one. Django templates can be hard to debug, especially to figure out which …
Read MoreNov. 26, 2024 » Adam Johnson » [Archived Version]
This post is an adapted extract from my book Boost Your Django DX, available now with a 50% discount for Black Friday 2024. Python’s breakpoint() function opens its debugger, pdb, which pauses the program and allows you to inspect and modify things. Let’s look at an example of …
Read MoreNov. 21, 2024 » Adam Johnson » [Archived Version]
Heavy refactoring of models can leave a Django project with “ghost tables”, which were created for a model that was removed without any trace in the migration history. Thankfully, by using some Django internals, you can find such tables. Use the database introspection methods table_names() to list all tables and …
Read MoreNov. 18, 2024 » Adam Johnson » [Archived Version]
Here are some Django-related deals for this year’s Black Friday (29th November) and Cyber Monday (1st December), including my own. I’ll keep this post up to date with any new deals I learn about. If you are also a creator, email me with details of your offer and …
Read MoreNov. 18, 2024 » Adam Johnson » [Archived Version]
I have just released the second update to Boost Your Django DX, my book of developer experience (DX) recommendations for Django projects. This update contains a new chapter, changes some recommended tools, and upgrades to Python 3.13 and Django 5.1. Overall, the book is 45 pages longer, now …
Read More