inserting a form to session raises picklingerror - django
- by shanyu
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.