How to wrap a Django Form Wizard in a View?

前端 未结 2 385
醉话见心
醉话见心 2021-01-06 05:33

This question is highly related to one that was previously asked and answered here: How wrap a FormWizard in a View?

Can someone post exact details of how they have

2条回答
  •  独厮守ぢ
    2021-01-06 06:08

    An alternative answer - instead of wrapping your view you could always use a decorator on your Wizardview class, as described in the documentation

    You would therefore do the following imports:

    from django.contrib.auth.decorators import login_required
    from django.utils.decorators import method_decorator
    

    and then within class createObjectWizard(SessionWizardView) you would add the following:

     @method_decorator(login_required)
     def dispatch(self, *args, **kwargs):
         return super(createObjectWizard, self).dispatch(*args, **kwargs)
    

    this way you don't have to mess with urls.py - it's all taken care of within the view. Hope this helps

提交回复
热议问题