开发者

Dajaxice form validation: "unicode object has no attribute get" (jquery serialize)

开发者 https://www.devze.com 2023-04-11 17:12 出处:网络
i have a big issue with dajax and jquery: i\'m trying to save the user\'s email with dajax, but i keep getting this error when form.is_valid() is called

i have a big issue with dajax and jquery: i'm trying to save the user's email with dajax, but i keep getting this error when form.is_valid() is called

 "unicode" object has no attribute "get"

i think this is because of jquery's serialize() method, which i'm using in this function:

function send_form(){
    data = $('#subscribe').serialize(true);
    data = decodeURIComponent(data);    
    Dajaxice.tothego_frontend.sito_maynard.subscribe(Dajax.process,{'form':data});
}

subscribe is my validation + registration method, which also contains is_valid()

as far as i've understood, the error happens because i'm trying to call the is_valid on a string, but i cannot see other ways to serialize my forms. also, on dajaxice example page the validation works fine. my code is pretty much the same, except i'm performing different operations after is_valid() call.

please, i really need some help, been trying everything since yesterday thanks!

EDIT: here's the stacktrace

and here's the form code:

class SubscriptionForm(forms.Form):

     email = forms.EmailField()
     what_sub = forms.CharField()
     where_sub = forms.CharField()
     url开发者_Python百科_sub = forms.CharField()

which, as i said at the beginning, is the same as dajaxice's example


i fixed it by changing

$('#subscribe').serialize(true)

into

$('#subscribe').serializeObject(true)

as i tought, the problem was the structure serialize creates, which isn't good for django form validation

0

精彩评论

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

关注公众号