调用带有URL参数的函数以获取.as_view()的参数是否可能?

时间:2019-05-31 16:08:36

标签: python django django-forms django-formwizard django-formtools

这是我当前的代码:

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'),

可以这样做吗?

0 个答案:

没有答案