擅长:python、mysql、java
<p>解决了这个问题,我添加了一个引用归档视图的辅助函数</p>
<pre><code>class MonthlySum(RedirectView):
def get_redirect_url(self, *args, **kwargs):
today = timezone.now()
return reverse(
'month-archive',
kwargs={
'month': today.month,
'year': today.year,
}
)
</code></pre>
<p>在URL中</p>
<pre><code>path('offering/report/<int:year>/<int:month>/',views.OfferingMonthArchiveView.as_view(),name="month-archive"),
</code></pre>