无法导入名称FormWizard

时间:2014-02-04 06:57:01

标签: python django django-formwizard

使用“来自django.contrib.formtools.wizard导入FormWizard” 在forms.py中继承特定表单类中的formwizard。 然后得到以下错误:

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

为上述问题添加回溯,希望这会提供一些帮助:

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

3 个答案:

答案 0 :(得分:1)

FormWizard已不再使用。来自Django 1.4 release notes

  

来自django.contrib.formtools的前一个FormWizard已经被基于Django 1.3中引入的基于类的视图的新实现所取代。它具有可插入的存储API,并且不需要向导传递前一步的隐藏字段。

     

有关详细信息,请参阅form wizard文档。

答案 1 :(得分:1)

我建议你将virtualenv重新生成你的分数。 您将代码从ubuntu移动到cent os,因此可能存在python版本的问题。

答案 2 :(得分:1)

有一种可能性:你在lib文件夹中有两个django dir。一个是django1.3.1,其他可能是django 1.6.1或更高版本:

如果你已经删除了任何你申请不需要的人。