Hi hope someone can help, I've been trying out form wizard for a project and have been following the documentation closely, but keep getting this error:
'NoneType' object has no attribute 'rsplit'
forms.py:
from django import forms
class ContactForm1(forms.Form):
subject = forms.CharField()
sender = forms.CharField()
class ContactForm2(forms.Form):
message = forms.CharField()
views.py:
class ContactWizard(WizardView):
def done(self, form_list, **kwargs):
return render_to_response('done.html', {
'form_data': [form.cleaned_data for form in form_list],
})
and urls.py (atestapp is 'woo')
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^woo/', ContactWizard.as_view([ContactForm1, ContactForm2]))
]
Traceback:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/woo/
Django Version: 1.8.4
Python Version: 3.4.0
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'formtools')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware')
Traceback:
File "C:\Python34\lib\site-packages\django\core\handlers\base.py" in get_response
132. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Python34\lib\site-packages\django\views\generic\base.py" in view
71. return self.dispatch(request, *args, **kwargs)
File "C:\Users\pdelarosa\AppData\Roaming\Python\Python34\site-packages\formtools\wizard\views.py" in dispatch
235. getattr(self, 'file_storage', None))
File "C:\Users\pdelarosa\AppData\Roaming\Python\Python34\site-packages\formtools\wizard\storage\__init__.py" in get_storage
13. storage_class = import_string(path)
File "C:\Python34\lib\site-packages\django\utils\module_loading.py" in import_string
21. module_path, class_name = dotted_path.rsplit('.', 1)
Exception Type: AttributeError at /woo/
Exception Value: 'NoneType' object has no attribute 'rsplit'
whenever I go to the woo/ url it just shows the nonetype error split. I've tried redoing the whole thing but still get the same error. Hope someone can help.
Instead of subclassing WizardView, try subclassing SessionWizardView:
from formtools.wizard.views import SessionWizardView
class ContactWizard(SessionWizardView):
...
The documentation isn't very clear on this, but in most cases you shouldn't subclass WizardView directly - instead there are a number of sub-views that you should use:
SessionWizardView
CookieWizardView
NamedUrlWizardView etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With