today = datetime.datetime.today()
this_friday = today + datetime.timedelta((calendar.FRIDAY - today.weekday()) % 7)
base_date = this_friday.date()
stock_qs = StockPrice.objects.filter(ticker_id=3)
stock_qs = stock_qs.values('date').annotate(group_id=(base_date - F('date'))/ datetime.timedelta(days=7))
s1 = stock_qs.annotate(weekly_bprc_adj=Window(
expression=FirstValue('bprc_adj'),
partition_by=[F('group_id')],
order_by=F('date').asc()
))
LINE 1: ...' * ('2021-05-07'::date - "stock_prices"."date")) / '7 days ...
^
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.