【发布时间】:2021-06-18 00:31:35
【问题描述】:
是否可以根据实例详细信息更新类中的列表?
我想做这样的事情:
from formtools.wizard.views import SessionWizardView
class ContactWizard(SessionWizardView):
form_list = [ # a list of forms used per step
(S1, Q1),
(S2, Q2),
(S3, Q3),
]
def form_updater(self):
if self.get_cleaned_data_for_step("0") != None:
form_list.append((S3, Q3),)
return form_list
#However, I get thrown an error when I try to make the following call:
ContactWizard.form_updater(ContactWizard)
## error:
get_cleaned_data_for_step() missing 1 required positional argument: 'step'
非常感谢您提供的任何帮助或指导。
【问题讨论】:
-
你在哪里打电话
ContactWizard? -
课外。如果我尝试在类中调用它,它的名称将无法识别。
-
请显示您用来调用它的代码
-
@LordElrond 我更新了我的帖子以澄清我的通话结构。这应该是可复制的。
标签: python-3.x django django-views django-formwizard