Posts tagged ‘django’


Using Django Check Constraints to Prevent Self-Following

This puppy would follow you anywhere.

Another way to use Django’s CheckConstraint class to ensure your data is valid. Based on my answer to a question on the Django forum.

Read more...

Improve your Django experience with IPython

Make your shell better

IPython is an improved Python shell for interactive use. It has many great features such as syntax highlighting, autocomplete, and powerful “magic commands”. I love it, use it on every project, and use the IPython prompt for examples on my blog.

Read more...

Django’s release code words, up until 3.2

A true cornucopia of words

It’s now a long-running tradition that each Django release has an associated “code word”. This is used by the release manager in the announcement blog post to describe the list of features coming in the next version.

Read more...

New Testing Features in Django 3.2

A veritable treasure trove of improvements.

Django 3.2 had its first alpha release a couple of weeks ago and the final release will be out in April. It contains a mezcla of new features, which you can check out in the release notes. This post focuses on the changes to testing, a few of which you can get on earlier Django versions with backport packages.

Read more...

Using Django Check Constraints to Limit A Model to a Single Instance

A most singular unicorn.

Yet another use case for creating a database constraint with Django’s CheckConstraint class.

Read more...

Using Django Check Constraints to Prevent the Storage of The Empty String

Go team dog!

Here’s another use case for creating a database constraint with Django’s CheckConstraint class.

Read more...

How to Limit Test Time in Django’s Test Framework

Take some time out

I recently optimized a client project’s test suite, and in the process found a test whose runtime had crept up ever since it had been written. The problematic test exercised an import process from a fixed past date until the current day. The test’s runtime therefore grew every day, until it reached over a minute.

Read more...

Reading CloudFlare headers in a Django middleware

From the Land of the Long White Cloud

For my new Django project, DB Buddy, I’m using CloudFlare as my CDN. It has a bunch of useful features that would otherwise take extra work, such as DDoS protection, HTML minification, and analytics.

Read more...

Simple In-Memory Caching of Django Model Data With cachetools

Them’s the United States of America!

A client project recently was suffering from an N+1 queries problem in a complicated Django admin page. Many measures had already been taken to prevent N+1 queries, such as use of django-auto-prefetch and some manually tuned select_related() / prefetch_related() calls. The remaining N+1 in question was a bit resistant to those methods because it came through several layers of admin code and many-to-many fields, making it harder than normal to find the place to modify the QuerySet construction.

Read more...

Efficient Reloading in Django’s Runserver With Watchman

Go set a watchman.

If you start the development server on a Django project, it looks something like this:

Read more...

All tags: