[英]Django formtools and instance variable for form instance
我正在使用Django formtools創建多步驟表單。 問題是我不知道如何將唯一ID傳遞給表單實例。 像這樣:
但是,這怎么辦呢? 沒有初始化可利用。 另一方面,initial_dict將在所有表單實例中保持不變,並且不滿足第4點。
任何想法如何解決這個問題?
也許嘗試這樣的事情:
class MyWizardView(SessionWizardView):
unique_id == ""
def get(self, request, *args, **kwargs):
"""
This method handles GET requests.
If a GET request reaches this point, the wizard assumes that the user
just starts at the first step or wants to restart the process.
The data of the wizard will be resetted before rendering the first step
"""
self.storage.reset()
# reset the current step to the first step.
self.storage.current_step = self.steps.first
unique_id = # Insert ID generator here #
return self.render(self.get_form())
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.