문제

On using "from django.contrib.formtools.wizard import FormWizard" in forms.py to inherit formwizard in a particular form class. then getting following error:

ImportError at /APPLICATION/ashish

cannot import name FormWizard

Request Method:  POST
Request URL:  http://ec2-401-10-25-259.compute-1.amazonaws.com/APPLICATION/ashish
Django Version:  1.3.1
Exception Type:  ImportError
Exception Value:  

cannot import name FormWizard

Exception Location:  /var/www/STACK/DJANGO/PROJECT/APPLICATIO`enter code here`N/myapp/forms.py in <module>, line 28
Python Executable:  /usr/bin/python
Python Version:  2.6.6
Python Path:  

['/var/www/STACK/DJANGO/PROJECT/APPLICATION',
 '/usr/lib64/python26.zip',
 '/usr/lib64/python2.6',
 '/usr/lib64/python2.6/plat-linux2',
 '/usr/lib64/python2.6/lib-tk',
 '/usr/lib64/python2.6/lib-old',
 '/usr/lib64/python2.6/lib-dynload',
 '/usr/lib64/python2.6/site-packages',
 '/usr/lib/python2.6/site-packages',
 '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info',
 '/var/www/STACK/DJANGO/']

Server time:  Tue, 4 Feb 2014 01:41:14 -0500

Adding traceback for the above issue, hope this would provide some help:

TRACEBACK::


File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/var/www/stacks/django-apps/hive/apps/accounts/views.py" in sms_code
  159.             return HttpResponseRedirect(reverse('login'))
File "/usr/lib/python2.6/site-packages/django/core/urlresolvers.py" in reverse
  391.             *args, **kwargs)))
File "/usr/lib/python2.6/site-packages/django/core/urlresolvers.py" in reverse
  312.         possibilities = self.reverse_dict.getlist(lookup_view)
File "/usr/lib/python2.6/site-packages/django/core/urlresolvers.py" in _get_reverse_dict
  229.             self._populate()
File "/usr/lib/python2.6/site-packages/django/core/urlresolvers.py" in _populate
  208.                     for name in pattern.reverse_dict:
File "/usr/lib/python2.6/site-packages/django/core/urlresolvers.py" in _get_reverse_dict
  229.             self._populate()
File "/usr/lib/python2.6/site-packages/django/core/urlresolvers.py" in _populate
  197.         for pattern in reversed(self.url_patterns):
File "/usr/lib/python2.6/site-packages/django/core/urlresolvers.py" in _get_url_patterns
  279.         patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/lib/python2.6/site-packages/django/core/urlresolvers.py" in _get_urlconf_module
  274.             self._urlconf_module = import_module(self.urlconf_name)
File "/usr/lib/python2.6/site-packages/django/utils/importlib.py" in import_module
  35.     __import__(name)

File "/var/www/STACK/DJANGO/PROJECT/APPLICATION/myapp/views.py" in <module>
  15. from forms import HivReportForm, HivReportFormNew, CrossCheckForm 
File "//var/www/STACK/DJANGO/PROJECT/APPLICATION/myapp/forms.py" in <module>
  28. from django.contrib.formtools.wizard import FormWizard

Exception Type: ImportError at /accounts/smscode/
Exception Value: cannot import name FormWizard
도움이 되었습니까?

해결책

There is one possibility : you have two django dir in lib folder . one is django1.3.1 and other may be django 1.6.1 or higher version:

if you have then remove it anyone which is not required for your application.

다른 팁

FormWizard is no longer used. From the Django 1.4 release notes:

The previous FormWizard from django.contrib.formtools has been replaced with a new implementation based on the class-based views introduced in Django 1.3. It features a pluggable storage API and doesn’t require the wizard to pass around hidden fields for every previous step.

See the form wizard docs for more information.

I will suggest you to regenerate your virtualenv into your cent os . You move your code from ubuntu to cent os so there might be issue with python version.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top