web | https://adamj.eu/ |
---|---|
Author | Adam Johnson |
Dec. 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 MoreSept. 25, 2024 » Adam Johnson » [Archived Version]
Happy DjangoCon US 2024 to you. Whilst I am not there, I have adopted the spirit of the season and got to work hacking together a new tool. Djade is a formatter for Django templates. It applies rules based on the template style guide in Django’s contribution documentation, plus …
Read MoreSept. 17, 2024 » Adam Johnson » [Archived Version]
Django’s test client provides two methods to log in a user: login() and force_login(). The latter one is faster because it bypasses the authentication backend, including password hashing, and just sets a session to have the user logged in. Typically, you’d want to use it in setUp() like …
Read MoreSept. 7, 2024 » Adam Johnson » [Archived Version]
Django provides us with a rich set of view decorators. In this post, we’ll look at a technique for hoisting repeated use of these decorators to reduce repetition. Repeated @cache_control calls Here are two public views with the same @cache_control decorator: from django.views.decorators.cache import cache_control @cache_control …
Read More