1👍
What have you tried? This is a place for question and answer, not just getting someone else to do the work.
To get you started:
SELECT SUM(column1) FROM table1
WHERE id_foo NOT IN ({ids_to_exclude}) AND bar < 1000 AND source = '{source}'
AND created >= '{start}' AND created < '{end}'
You should look at how to create models in django. You will need a table1 model to store your information. To create this query, you’ll also need to look at the queryset aggregates (Sum) and how to use .exclude(id_in=[ids_to_exclude]).
Source:stackexchange.com