一个简单的应用程序,包含一些用于向导实现的类和脚本。

btc-simple-wizard的Python项目详细描述


一个简单的应用程序,包含一些用于向导实现的类和脚本。在

详细文档在“docs”目录中。在

快速入门

  1. 将向导应用程序添加到项目设置中的项目应用程序列表:

    INSTALLED_APPS = [
        ...
        'simple_wizard'
    ]
    
  2. 将向导模式添加到基本模板:

    ^{pr2}$ 在
  3. 使用如下步骤构建管理视图:

    class WizardManagementView(WizardBaseView):
        """
        View for creating wizard with 3 steps
        """
    
        management_url_pattern = 'test_app:wizard_management'
        common_title = 'Common Title'  # for steps without own title
    
        class FirstStep(WizardModalStepMixin, TemplateView):
            """
            First step - simple modal with text message and continue button.
            """
    
            unique_name = 'message_step'
            template_name = 'simple_wizard/wizard_modal_message.html'
            message = 'Simple message step'
            cache_step = False  # step doesn't ask server on repeat show (if it already fetched)
            buttons = [
                LoadWizardStepButton(
                    load_step='form_step',  # next step (get request)
                    title='Continue',
                    css_classes=['btn btn-primary']
                )
            ]
    
        class SecondStep(WizardModalStepWithFormMixin, FormView):
            """
            Second step - modal with form (can be form or model form), validation supported.
            """
    
            unique_name = 'form_step'
            template_name = 'simple_wizard/wizard_modal_form.html'
            form_class = SecondStepForm
            redirect_to_step_if_valid = 'third_step'
            buttons = [
                LoadWizardStepPostButton(
                    load_step='form_step',
                    title='Continue',
                    css_classes=['btn btn-primary']
                )
            ]
    
            def form_valid(self, form):
                test_model = TestModel.objects.filter(pk=self.kwargs.ger('pk')).first()
                test_model.field_1 = form.cleaned_data.get('field_1')
                test_model.save()
    
            return super().form_valid(self, form):
    
        class ThirdStep(WizardModalStepWithFormMixin, TemplateView):
            """
            Third step - just a template modal
            """
    
            unique_name = 'third_step'
            template_name = 'third_step.html'
            buttons = [
                CloseWizardModalButton(
                    title='Finish',
                    css_classes=['btn btn-primary']
                )
            ]
    
  4. {tt1}设置

    app_name = 'test_app'
    
    ...
    
    urlpatterns = [
        ...
        path('wizard-management/<step_to_load>/<int:pk>/', WizardManagementView.as_view(), name='wizard_management')
    ]
    
  5. 为向导工作添加静态文件:

    <script src="{% static 'simple_wizard/wizard.js' %}"></script>
    
  6. 初始化向导处理程序:

    $(document).ready(function () {
        const django_modal_wizard = new DjangoModalWizard(
            '#wizard-modal',
            '.js-wizard_modal_content',
            '.js-load_wizard',
            '.js-close_wizard'
        );
        django_modal_wizard.initSignals();
    });
    

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
javascript{“错误”:[“无效图像URL”]}与鸟舍集成   mysql Java语句。executeUpdate(sql)在executeQuery(sql)工作时不工作   在java中反复编辑object/arrayList   java在创建子类实例时是否也创建了超类实例?   如果运行一定次数,java是否仍要生成else?   java gradle eclipse依赖项,跳过testCompile/ProviderRuntime等   java如何用Dozer实例化子类?   java如何在docker容器中高效地构建maven项目?   lambda我想在这个块中转换成java 8流?   java本地广播管理器使用主活动未接收到的警报   更新产品数量时发生java异常(自定义属性)   java在每次迭代后删除2d数组的列和行   java如何在一个片段中存储数据以在另一个片段中获取数据?   java将默认公共构造函数添加到生成的生成器内部类