Feed: Haki Benita

Blog Haki Benita
RSS 2.0 Feed Haki Benita
web https://hakibenita.com/
Last Update04.28.2026
Posts28

How to Let Google Know of Other Languages in Your Django Site

May 6, 2019 » Haki Benita » [Archived Version]

If you have a public facing Django site in multiple languages, you probably want to let Google and other search engines know about it.

Read More

How to Create an Index in Django Without Downtime

April 9, 2019 » Haki Benita » [Archived Version]

If you ever had to maintain a traffic heavy Django site, you probably had to deal with graceful migrations. In the article I explain what atomic and reversible migrations are, how to execute "raw" SQL in migrations the right way, and how using a little known migration command we can completely alter the Django migrations built-in behavior.

Read More

How to Use Grouping Sets in Django

March 9, 2019 » Haki Benita » [Archived Version]

How we cut a heavy admin dashboard response time in half with advanced SQL and some Django hackery. I recently had the pleasure of optimizing an old dashboard. The solution we came up with required some advanced SQL that Django does not support out of the box. In this article I present the solution, how we got to it, and a word of caution.

Read More

Modeling Polymorphism in Django

Jan. 1, 2019 » Haki Benita » [Archived Version]

Modeling polymorphism in relational databases is a challenging task. In this article, we present several modeling techniques to represent polymorphic objects in a relational database using the Django object-relational mapping (ORM).

Read More

Optimizing the Django Admin Paginator

Nov. 5, 2018 » Haki Benita » [Archived Version]

I often talk about making Django scale but what does it actually mean? It means getting consistent performance regardless of the amount of data. In this article we tackle The last nail in Django admin's scalability coffin - the paginator.

Read More

Automating the Boring Stuff in Django Using the Check Framework

June 4, 2018 » Haki Benita » [Archived Version]

Every team has a unique development style. Some teams implement localization and require translations. Some teams are more sensitive to database issues and require more careful handling of indexes and constraints. In this article we describe how we enforce our own development style using the Django check framework, the inspect and the ast modules from the Python standard library.

Read More

9 Django Tips for Working with Databases

Jan. 28, 2018 » Haki Benita » [Archived Version]

ORMs offer great utility for developers but abstracting access to the database has its costs. Developers who are willing to poke around the database and change some defaults often find that great improvements can be made.

Read More

How to Add a Text Filter to Django Admin

Jan. 1, 2018 » Haki Benita » [Archived Version]

Django Admin search fields are great, throw a bunch of fields in search_fields and Django will handle the rest. The problem with search field begins when there are too many of them. This is how we replaced Django search with text filters for specific fields, and made Django admin much faster.

Read More

Django Admin Range-Based Date Hierarchy

Dec. 10, 2017 » Haki Benita » [Archived Version]

A few weeks ago we encountered a major performance regression in one of our main admin pages. The page took more than 10 seconds to load (at best) and hit the query execution timeout at worst. When we investigated the issue, we found that the date hierarchy was the cause for most of the time spent loading the admin page. In the article we describe how we significantly improved the performance of Django Admin date hierarchy

Read More

Scaling Django Admin Date Hierarchy

Oct. 5, 2017 » Haki Benita » [Archived Version]

The date hierarchy is a great feature but it comes at a price. On very large tables, the way date hierarchy is implemented can make an admin page nearly unusable. In this article we describe the limitations of the date hierarchy, and suggest a way to overcome them.

Read More