开发者

FormWizard and saving data

开发者 https://www.devze.com 2023-01-11 21:18 出处:网络
im trying to use django formWizard, all is fine, but im getting an error in the last step after submit

im trying to use django formWizard, all is fine, but im getting an error in the last step after submit

    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'

i dont know where is the problem, in my Model i have a website field, but ... why the error?

model.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)

and in my forms:

forms.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'],
       开发者_Python百科     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/')

EDIT

urls.py

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


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

i dont know if im saving the data like formwizard need, but im trying.

any idea about the error?

thanks


As i have already used FormWizard in my app, the keys of submitted data are not 'website' or 'estado_civil',... but in the form "< form_number>-< field_name>". For example: '0-website' if the field 'website' is in the first form, '1-website' if it is in the second form and so on. You can print out the whole submitted data dictionary to check that.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号