-1

我正在尝试使用 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'

我不知道问题出在哪里,在我的模型中我有一个网站字段,但是......为什么会出错?

模型.py

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)

并以我的形式:

表格.py

#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/')

编辑

网址.py

from vacantes.curriculums.forms import Generales,Areas,Experiencia,Referencias,ContactWizard


urlpatterns = patterns('',
              url(r'^completar/$', ContactWizard([Generales, Areas,Experiencia,Referencias])),
)

我不知道我是否需要像 formwizard 那样保存数据,但我正在尝试。

关于错误的任何想法?

谢谢

4

1 回答 1

0

由于我已经在我的应用程序中使用了 FormWizard,因此提交数据的键不是“网站”或“estado_civil”,而是以“<form_number>-<field_name>”的形式。例如:'0-website' 如果字段 'website' 是第一种形式,'1-website' 如果它是第二种形式,依此类推。您可以打印出整个提交的数据字典来检查。

于 2011-08-16T16:56:59.803 回答