긴 폼을 처리하기 위해 FormWizard를 통합하려고합니다. 조사한 후에는 세션을 통해 formwizard를 관리하기 때문에 django-merlin이 가장 좋은 옵션입니다. 그러나이를 통합하려고 시도하면 (django wizard docs에서 언급 한 것처럼) AttributeError: type object 'CreateWizard' has no attribute 'as_view'
이됩니다. 여기 Django FormWizard as_view() 메서드 AttributeError
from merlin.wizards.session import SessionWizard
class StepOneForm(forms.Form):
year = forms.ChoiceField(choices=YEAR_CHOICES)
...
class StepTwoForm(forms.Form):
main_image = forms.ImageField()
...
class StepThreeForm(forms.Form):
condition = forms.ChoiceField(choices=CONDITION)
...
class CreateWizard(SessionWizard):
def done(self, form_list, **kwargs):
return HttpResponseRedirect(reverse('wizard-done'))
URL : 멀린의 문서가 조금 스파 스이기 때문에, 내가 원래 장고 양식에 설명 된대로 as_view()
방법을 사용하기로 결정했습니다
url(r'^wizard/(?P<slug>[A-Za-z0-9_-]+)/$', CreateWizard.as_view([StepOneForm, StepTwoForm, StepThreeForm])),
마법사 문서이지만, 결과는 AttributeError
입니다. urlconf에 merlin wizard를 어떻게 통합해야합니까? 당신의 아이디어에 감사드립니다!
step_one = Step('step_one', StepOneForm())
오류 및 역 추적 :
TypeError at/issubclass() arg 1 must be a class
Traceback:
File /lib/python2.7/django/core/handlers/base.py" in get_response
89. response = middleware_method(request)
File "/lib/python2.7/django/utils/importlib.py" in import_module
35. __import__(name)
File "/myproject/myproject/urls.py" in <module>
7. from myapp.forms import step_one, step_two, step_three, CreateWizard
File "/myproject/myapp/forms.py" in <module>
16. step_one = Step('step_one', StepOneForm())
File "/lib/python2.7/merlin/wizards/utils.py" in __init__
36. if not issubclass(form, (forms.Form, forms.ModelForm,)):
Exception Type: TypeError at/
Exception Value: issubclass() arg 1 must be a class
메신저 아직도 비록
이것은 내가 같이 @ mVChr의 대답을 기반으로 정의하는 단계를 업데이트 한 후 얻을 오류 및 역 추적입니다 오류가 발생하면 @mVChr 덕분에 솔루션에 더 가까이 다가 갈 수 있습니다. 이 오류를 해결하는 방법에 대한 아이디어는 대단히 감사하겠습니다! 어떤 아이디어 주셔서 감사합니다!
그냥'CreateWizard ([StepOneForm, StepTwoForm, StepThreeForm])'시도 했습니까? ([문서보기] (http://packages.python.org/django-merlin/sessionwizard.html#how-to-use-sessionwizard))? 또한 django'Form' 객체가 아니라 ['Step' objects] (http://packages.python.org/django-merlin/api/step.html#api-step)를 전달해야합니다. – mVChr
그러면 다른 오류가 발생합니다. 'TypeError at/모든 단계는 Step의 인스턴스 여야합니다.' merlin 소스 42 줄에있는 [here here] (https://github.com/supercodepoet/django-merlin/blob/master/src/merlin/wizards/session.py)입니다. 어떤 아이디어라도 제공해 주셔서 감사합니다! –
@mVChr : 당신의 아이디어에 감사드립니다. 양식 대신 단계 개체를 전달하는 방법을 설명하기 위해 작은 예제를 제공 할 수 있습니까?그러면이 문제를 해결하는 방법을 이해하는 데 도움이 될 것입니다. –