Dajaxice form validation: "unicode object has no attribute get" (jquery serialize)
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
精彩评论