But before, is it possible to serialize a form in JSON ?
Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe
But beforce, is it possible to serialise a form in JSON ?
Thanks
On 11 fév, 00:50, adrian wrote:
> Thank you all for posting this. You saved me probably hours of head
> scratching.
--~--~-~--~~~---~--~~
You received this message because you
Thank you all for posting this. You saved me probably hours of head
scratching.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to
I ran into this same problem but the code snippets you guys gave
weren't working. In case anyone is reading this in the future, here is
what you want:
dict([(k, [unicode(e) for e in v]) for k,v in errors.items()])
The above line will give a dictionary of field names mapping to lists
of errors.
Hi Russell,
I bumped into the same issue today and was glad I found this post.
However, I found that I had to use unicode() rather than str(),
which turns your example into:
content = dict((key, [unicode(v) for v in values]) \
for key, values in
On Sun, Oct 19, 2008 at 12:58 AM, justind <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> No one has any ideas?
Settle down, Tiger. You asked this question on a Friday night. You may
need to wait a little more than 18 hours if you want a response.
We're all volunteers here, and many of us have
Actually the test form is (I forgot to change the name)
class MyForm(forms.Form):
text = forms.CharField()
link = forms.URLField()
On Oct 18, 4:21 pm, justind <[EMAIL PROTECTED]> wrote:
> I get exactly the same thing.
>
> Here's what I'm entering.
>
> >>> import simplejson
> >>>
I get exactly the same thing.
Here's what I'm entering.
>>> import simplejson
>>> simplejson
>>> from myproject.app.models import MyForm
>>> f = MyForm({'link': 'footext'})
>>> f.errors
{'text': [u'This field is required.'], 'link': [u'Enter a valid
URL.']}
>>> simplejson.dumps(f.errors)
Could you try this with simplejson not bundled with Django? If that works
this is probably a bug in the version bundled with Django.
On Sat, Oct 18, 2008 at 6:58 PM, justind <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> No one has any ideas?
>
> The code I'm actually using in my view is almost
Hello,
No one has any ideas?
The code I'm actually using in my view is almost identical to the
validage_contact view from
http://toys.jacobian.org/presentations/2007/oscon/tutorial/ (single
slide:
http://toys.jacobian.org/presentations/2007/oscon/tutorial/images/django-master-class.081.png)
Hello,
I'm having a hard time understanding why Django won't let me serialize
a dictionary of form errors. Can anyone explain why Django throws an
error if I try to serialize someform.errors, even if I copy it into a
plain dictionary?
#!/usr/bin/env python
from django.utils import simplejson
11 matches
Mail list logo