@bmispelon I did some research and you are right. Custom aggregates are the cleanest solution for this problem and it can be as simple as:
```class Median(Aggregate):
template = 'PERCENTILE_CONT(.5) WITHIN GROUP (ORDER BY %(field)s)'```
Unfortunately, it should't be possible to have built-in, as median isn't an ANSI SQL function, so a different implementation is needed for each DB (the one I tested in PostgreSQL).
The hack also is worried about annotations. Need to test a bit more.