这是我当前的代码:
form_list = [PilotForm, BriefingsForm]
...
url(r'^inspections/(?P<inspection_type_id>[0-9]+)/new-inspection/$', InspectionWizard.as_view(form_list), name='new_inspection'),
我要实现的目的是使我可以有一个函数,该函数可以根据Inspection_type_id(URL参数)动态返回form_list:
它看起来像:
def get_form_list(inspection_type_id):
forms_list = []
# dynamically filter forms and add to forms_list
return forms_list
...
url(r'^inspections/(?P<inspection_type_id>[0-9]+)/new-inspection/$', InspectionWizard.as_view(get_form_list(inspection_type_id), name='new_inspection'),
可以这样做吗?