2
私のサイトのイベントのMonthArchiveViewがあります。どのように私は何年と月が提出されていない場合、例外を発生させるのではなく、現在の月のアーカイブのデフォルトを作ることができます(ユーザーの訪問はちょうど/イベントは、/?MonthArchiveViewの現在の月のデフォルト
# urls.py
url(r'^events/$', EventMonthView.as_view(), name="event_month"),
url(r'^events/(?P<year>[0-9]{4})/(?P<month>[0-9]+)/$', EventMonthView.as_view(month_format='%m'), name="event_month"),
#views.py
class EventMonthView(MonthArchiveView):
template_name = "events.html"
queryset = Event.objects.all()
date_field = "date"
allow_future = True
month_format='%m'
year_format='%Y'
魅力的に動作します。本当に助けていただきありがとうございます。 – setchock