即时尝试使用django formWizard,一切都很好,但我在提交后的最后一步收到错误
Traceback (most recent call last):
File "/home/vacantes/webapps/django/lib/python2.6/django/core/handlers/base.py", line 100, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/home/vacantes/webapps/django/lib/python2.6/django/utils/decorators.py", line 21, in _wrapper
return decorator(bound_func)(*args, **kwargs)
File "/home/vacantes/webapps/django/lib/python2.6/django/utils/decorators.py", line 76, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/home/vacantes/webapps/django/lib/python2.6/django/utils/decorators.py", line 17, in bound_func
return func(self, *args2, **kwargs2)
File "/home/vacantes/webapps/django/lib/python2.6/django/contrib/formtools/wizard.py", line 101, in __call__
return self.done(request, final_form_list)
File "/home/vacantes/webapps/django/hay_vacantes/curriculums/forms.py", line 56, in done
website = data['website']
TypeError: __init__() got an unexpected keyword argument 'website'
我不知道问题出在哪里,在我的模型中我有一个网站字段,但是......为什么会出错?
class Generales(models.Model):
usuario = models.OneToOneField(User,unique=True)
.....
estado_civil = models.SmallIntegerField(max_length=1,choices=CIVIL)
website = models.URLField(verbose_name='Website', verify_exists=False,null=True,blank=True)
以我的形式:
#others forms
.....
class ContactWizard(FormWizard):
def done(self, request, form_list):
data = {}
for form in form_list:
data.update(form.cleaned_data)
generales = Generales(
usuario = request.user.id,
documento_identidad = data['documento_identidad'],
tipo = data['tipo'],
tel_fijo = data['tel_fijo'],
celular = data['celular'],
foto = data['foto'],
sexo = data['sexo'],
direccion = data['direccion'],
codigo_postal = data['codigo_postal'],
pais = data['pais'],
ciudad = data['ciudad'],
fecha_nacimiento = data['fecha_nacimiento'],
estado_civil = data['estado_civil'],
website = data['website']
)
generales.save()
# others forms
.....
return HttpResponseRedirect('/panel/completo/')
urls.py
from vacantes.curriculums.forms import Generales,Areas,Experiencia,Referencias,ContactWizard
urlpatterns = patterns('',
url(r'^completar/$', ContactWizard([Generales, Areas,Experiencia,Referencias])),
)
我不知道我是否需要保存像formwizard这样的数据,但是我正在尝试。
关于错误的任何想法?
感谢
答案 0 :(得分:0)
由于我已经在我的应用中使用了FormWizard,因此提交数据的密钥不是'website'或'estado_civil',...而是以“< form_number> - < field_name>”的形式。例如:'0-website'如果字段'website'是第一种形式,'1-website'如果它是第二种形式,依此类推。 您可以打印出整个提交的数据字典来检查。