Sitemap

How Django Uses Python Properties and Descriptors

18 min readMar 22, 2020

Before you continue reading: this is an intermediate-and-above level Python article. In order to fully engage with the concepts in this article, you’ll need to be familiar with basic Django concepts and have a solid grasp of Python’s object-oriented programming model. This article is a continuation our deep-dive from Part I: How Django Uses Metaclasses For Data Modelling.

In this article, we’ll specifically focus on Django’s use of Python properties and their lower-level descriptor implementations. If you’re not sure what either of these terms mean, not to worry. We’ll walk through simple examples and build up to the complex machinery underpining parts of Django’s attribute lookup functionality. For the majority of our examples, we’ll use the same identical Student Django model as we did in Part I:

Before we begin diving into the code, let’s take consider what problems we might be trying to solve.

Design Principles for Web Application Performance

When we think about architecting highly-performant web applications, a few considerations come to mind, as general rules of thumb:

  • Request latency is often dominated by (as measured by the…

--

--

Yu Chen
Yu Chen

Written by Yu Chen

Software engineer focused on ML and distributed systems

No responses yet