I have a query:
query = Usage.query.filter_by(site_id=self.site_id, invoice_num=self.invoice_num, supply_charge=self.supply_charge)
And want to filter by dates:
.filter(Usage.start_date>four_months_ago)
only if the row getting filtered has the same value:
if subtotal == self.subtotal
Is there a better way of doing this than making a for loop? It seems very inefficient.
for row in query.all():
if self.start_date > four_months_ago:
if row.subtotal != self.subtotal:
del row