inserting a form to session raises picklingerror - django

Posted by shanyu on Stack Overflow See other posts from Stack Overflow or by shanyu
Published on 2010-01-29T13:35:43Z Indexed on 2010/06/06 7:02 UTC
Read the original article Hit count: 296

Filed under:

I receive an exception when I add a form to the session:

PicklingError: Can't pickle <class 'django.utils.functional.__proxy__'>: attribute lookup django.utils.functional.__proxy__ failed

The form includes a few simple fields and has some javascript attached to a widget. It might be that Django forms cannot be pickled at all, but the exception seems to point to unicode lazy translation.

To test further, I have also tried to insert only the form errors (an errordict) to the session and received the same error.

I appreciate some help here, thanks in advance.

EDIT: Here's why I insert a form into the session:

I have an app that has a form. This form is rendered by a template tag in another app. When posted, if the form is valid, no problem, I do stuff and redirect to "next". However if it is not valid, I want to go back to the posting page to show errors. Recall that the comments app in this case redirects to an intermediate "hey, please fix the errors" page. I am trying to avoid this, and hence redirect back to the posting page with the form and its errors in the session that the template tag will render.

© Stack Overflow or respective owner

Related posts about django