django-planet

Blog: Tinker, Tamper, Alter, Fry

web https://blog.ploetzli.ch
Author Henryk Plötz

Understanding Common Table Expressions in SQL

Aug. 4, 2020 » Tinker, Tamper, Alter, Fry » [Archived Version]

One of the lesser known features of modern SQL are so-called “Common Table Expressions” (CTE) or “WITH queries”. I’ll explain the mental model that helped me make sense of them, and how to use them to execute recursive queries. Afterwards I’ll show how to apply these techniques in Django.Syntactically a CTE consists of one or […]

Read More

An Efficient Multi-Stage Build for Python Django in Docker

June 21, 2020 » Tinker, Tamper, Alter, Fry » [Archived Version]

We’ve recently begun dockerizing our applications in an effort to make development and deployment easier. One of the challenges was establishing a good baseline Dockerfile which can maximize the benefits of Dockers caching mechanism and at the same time provide minimal application images without any superfluous contents.The basic installation flow for any Django project (let’s […]

Read More

Showing SQL Queries with Pytest and Django

Nov. 20, 2019 » Tinker, Tamper, Alter, Fry » [Archived Version]

I have a Django based project, and am doing unit tests with py.test. To debug a test failure it’s sometimes useful to see the actual SQL queries that Django emitted, which is surprisingly hard. I assumed that that would be such an obvious and common need, that a simple switch (for pytest-django) or easy plugin […]

Read More