You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As we were in a rush to fix dining menus, we left out key error catching! Here is one example. Help us verify the date and make sure it is within range (if today is Monday, then we want the date to be no further than next Sunday).
The text was updated successfully, but these errors were encountered:
classMenus(generics.ListAPIView):
""" GET: returns list of menus, defaulted to all objects within the week, and can specify the filter for a particular day """serializer_class=DiningMenuSerializerdefget_queryset(self):
ifdate_param:=self.kwargs.get("date"):
date=make_aware(datetime.datetime.strptime(date_param, "%Y-%m-%d"))
ifdate<timezone.now().date():
raiseHttp404elifdate>timezone.now().date() +datetime.timedelta(days=6):
raiseHttp404returnDiningMenu.objects.filter(date=date)
else:
start_date=timezone.now().date()
end_date=start_date+datetime.timedelta(days=6)
returnDiningMenu.objects.filter(date__gte=start_date, date__lte=end_date)
As we were in a rush to fix dining menus, we left out key error catching! Here is one example. Help us verify the date and make sure it is within range (if today is Monday, then we want the date to be no further than next Sunday).
The text was updated successfully, but these errors were encountered: