Brad's Blog

Published: 2015-10-18

A custom __date lookup for Django

database django lookups orm postgres python

⚠ Django 1.9 now includes a built-in __date lookup. If possible, you should use that instead of the code below, which doesn't support timezones. In my post last week on date lookups, I ended with a promise to take a look at building a custom django lookup (namely, a __date lookup). Django includes a basic Lookup class, and to build your own lookup expressions, all you really need to do is: Subclass django.db.models.Lookup define a ...


Published: 2015-10-10

Date lookups in Django

database django lookups orm postgres python

A while ago I tweeted out something that I've wanted to see in Django for a very long time, yet have never really taken the time to investigate or implement it: I wish #django had this: M.objects.filter(datetimefield__date=http://t.co/MVFXsN4Ivk(2015, 6, 29)) Has that ever been attempted?— Brad Montgomery (@bkmontgomery) June 29, 2015 Django's ORM has a very rich set of field lookups, but at present, it doesn't support an exact ...


Published: 2012-03-03

Streaming Replication in PostgreSQL 9.1

database postgresql

Not long ago, I set up synchronous, streaming replication in PostgreSQL 9.1 in order to build a Hot Standby system. This is the story of that journey. This post is mostly based on the 5-minute simple replication tutorial from the PostgreSQL wiki, but with a few modifications and clarifications. There's also lots of good information in the Streaming Replication wiki from the PostgreSQL wiki. For the remainder of this post, assume that you have a Master at 111 ...