當前位置: 首頁>>代碼示例>>Python>>正文


Python forms.ManagementForm方法代碼示例

本文整理匯總了Python中django.contrib.formtools.wizard.forms.ManagementForm方法的典型用法代碼示例。如果您正苦於以下問題:Python forms.ManagementForm方法的具體用法?Python forms.ManagementForm怎麽用?Python forms.ManagementForm使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.contrib.formtools.wizard.forms的用法示例。


在下文中一共展示了forms.ManagementForm方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: block_before_fieldsets

# 需要導入模塊: from django.contrib.formtools.wizard import forms [as 別名]
# 或者: from django.contrib.formtools.wizard.forms import ManagementForm [as 別名]
def block_before_fieldsets(self, context, nodes):
        context = context.update(dict(self.storage.extra_data))
        context['wizard'] = {
            'steps': self.steps,
            'management_form': ManagementForm(prefix=self.prefix, initial={
                'current_step': self.steps.current,
            }),
        }
        nodes.append(loader.render_to_string('xadmin/blocks/model_form.before_fieldsets.wizard.html', context)) 
開發者ID:stormsha,項目名稱:StormOnline,代碼行數:11,代碼來源:wizard.py

示例2: block_before_fieldsets

# 需要導入模塊: from django.contrib.formtools.wizard import forms [as 別名]
# 或者: from django.contrib.formtools.wizard.forms import ManagementForm [as 別名]
def block_before_fieldsets(self, context, nodes):
        context.update(dict(self.storage.extra_data))
        context['wizard'] = {
            'steps': self.steps,
            'management_form': ManagementForm(prefix=self.prefix, initial={
                'current_step': self.steps.current,
            }),
        }
        nodes.append(loader.render_to_string('xadmin/blocks/model_form.before_fieldsets.wizard.html',context)) 
開發者ID:Liweimin0512,項目名稱:ImitationTmall_Django,代碼行數:11,代碼來源:wizard.py

示例3: prepare_form

# 需要導入模塊: from django.contrib.formtools.wizard import forms [as 別名]
# 或者: from django.contrib.formtools.wizard.forms import ManagementForm [as 別名]
def prepare_form(self, __):
        # init storage and step helper
        self.prefix = normalize_name(self.__class__.__name__)
        self.storage = get_storage(
            self.storage_name, self.prefix, self.request,
            getattr(self, 'file_storage', None))
        self.steps = StepsHelper(self)
        self.wizard_goto_step = False

        if self.request.method == 'GET':
            self.storage.reset()
            self.storage.current_step = self.steps.first

            self.admin_view.model_form = self.get_step_form()
        else:
            # Look for a wizard_goto_step element in the posted data which
            # contains a valid step name. If one was found, render the requested
            # form. (This makes stepping back a lot easier).
            wizard_goto_step = self.request.POST.get('wizard_goto_step', None)
            if wizard_goto_step and int(wizard_goto_step) < len(self.get_form_list()):
                obj = self.get_form_list().keys()
                if six.PY3:
                    obj = [s for s in obj]
                self.storage.current_step = obj[int(wizard_goto_step)]
                self.admin_view.model_form = self.get_step_form()
                self.wizard_goto_step = True
                return

            # Check if form was refreshed
            management_form = ManagementForm(
                self.request.POST, prefix=self.prefix)

            if not management_form.is_valid():
                raise ValidationError(
                    'ManagementForm data is missing or has been tampered.')

            form_current_step = management_form.cleaned_data['current_step']
            if (form_current_step != self.steps.current and
                    self.storage.current_step is not None):
                # form refreshed, change current step
                self.storage.current_step = form_current_step

            # get the form for the current step
            self.admin_view.model_form = self.get_step_form() 
開發者ID:stormsha,項目名稱:StormOnline,代碼行數:46,代碼來源:wizard.py

示例4: prepare_form

# 需要導入模塊: from django.contrib.formtools.wizard import forms [as 別名]
# 或者: from django.contrib.formtools.wizard.forms import ManagementForm [as 別名]
def prepare_form(self, __):
        # init storage and step helper
        self.prefix = normalize_name(self.__class__.__name__)
        self.storage = get_storage(
            self.storage_name, self.prefix, self.request,
            getattr(self, 'file_storage', None))
        self.steps = StepsHelper(self)
        self.wizard_goto_step = False

        if self.request.method == 'GET':
            self.storage.reset()
            self.storage.current_step = self.steps.first

            self.admin_view.model_form = self.get_step_form()
        else:
            # Look for a wizard_goto_step element in the posted data which
            # contains a valid step name. If one was found, render the requested
            # form. (This makes stepping back a lot easier).
            wizard_goto_step = self.request.POST.get('wizard_goto_step', None)
            if wizard_goto_step and int(wizard_goto_step) < len(self.get_form_list()):
                self.storage.current_step = self.get_form_list(
                ).keys()[int(wizard_goto_step)]
                self.admin_view.model_form = self.get_step_form()
                self.wizard_goto_step = True
                return

            # Check if form was refreshed
            management_form = ManagementForm(
                self.request.POST, prefix=self.prefix)

            if not management_form.is_valid():
                raise ValidationError(
                    'ManagementForm data is missing or has been tampered.')

            form_current_step = management_form.cleaned_data['current_step']
            if (form_current_step != self.steps.current and
                    self.storage.current_step is not None):
                # form refreshed, change current step
                self.storage.current_step = form_current_step

            # get the form for the current step
            self.admin_view.model_form = self.get_step_form() 
開發者ID:Liweimin0512,項目名稱:ImitationTmall_Django,代碼行數:44,代碼來源:wizard.py


注:本文中的django.contrib.formtools.wizard.forms.ManagementForm方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。