Skip to content
Advertisement

django: group by extracting month and year from a date

im trying to get a list of invoicepositions where there hasn’t been payed an payout to a person.

Looking in the internet i came to this “Solution”

but the query, that comes out is:

so he added “created_at” and the id from the invoiceposition model although i don’t want that!

for example i have the following 4 lines in the db:

then i just want

(i’m running the query with designer_id 3)

Advertisement

Answer

It’s hard guessing what you want with such little information. But based on the input and output you provided, the following should do the trick.

Filter first for objects, then select distinct month and year of it.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement