I am afraid that using Django ORM this is not possible. The reason is,
the real SQL query would look something like:
select distinct writer from (
select writer from books where year = 2012 order by writer limit 5
);
And Django ORM just can't do that query for you. You might want to do
a raw SQL query, or just do the "distinct" step in Python, which is
probably the easiest solution (set() is your friend here).
Of course, if you want the first 5 distinct writers, thats easy to do.
But getting the distinct writer values in the 5 first rows is harder
to do.
- Anssi