0
爲什麼MonthArchiveView中的get_queryset()
返回來自我的模型的所有對象,而僅在請求的月份中返回對象created
?MonthArchiveView中的get_queryset()返回所有對象,而不是僅在請求的月份內創建的對象
class BudgetMonthlyView(MonthArchiveView):
template_name = 'budget/monthly.html'
model = FinanceData
date_field = "created"
make_object_list = False
allow_future = False
month_format = '%m'
def get_context_data(self, **kwargs):
context = super(BudgetMonthlyView, self).get_context_data(**kwargs)
print(self.get_queryset()) #return all objects from FinanceData model
print(context['object_list']) #works fine
return context
請添加FinanceData – e4c5