I think I am just putting this code in the wrong place but was wondering if someone could help out here. I wanted to get an item from the db for the last business day. This works fine, but it seems the below gets compiled when i start the app with gunicorn. So now the current_b_day is evaluated as 11/13 (today = 11/16). But this never changes. So my viewset will always return the same dataset even though i am adding new data to the db via an alternate process. If i bring the server down and back up, it will recompile and get a new value for current_b_day. Any help is much appreciated!
views.py
from pandas.tseries.offsets import BDay, BMonthEnd, BYearEnd
from datetime import date, datetime
class YieldCurveViewSet(viewsets.ModelViewSet):
current = date.today()
current_b_day = current - BDay(1) #This never changes and is compiled in!
queryset = YieldCurve.objects.filter(create_date=current_b_day)
serializer_class = YieldCurveSerializer