DetailView で、URL 文字列から渡された kwargs['party_id'] にアクセスできないのはなぜですか?
Test url: http://127.0.0.1:8000/party/3/activity/2/
urls.py
url(r'^party/(?P<party_id>\d*)/activity/(?P<pk>\d*)/$', ActivityView.as_view(), name='activity')
ビュー.py
class ActivityView(DetailView):
template_name = "ooe/activity_results.html"
context_object_name = "activity"
model = Activity
def get_context_data(self, **kwargs):
context = super(ActivityView, self).get_context_data(**kwargs)
#this line is not working because kwargs is just: {'object': <Activity: Activity 2>}
context['submissions'] = self.get_object().get_submissions(kwargs['party_id'])
return context
@method_decorator(user_passes_test(active_participant))
def dispatch(self, *args, **kwargs):
return super(ActivityView, self).dispatch(*args, **kwargs)