这是我当前的代码:
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'),
是否有可能做到这一点 ?