Opened 6 years ago
Closed 6 years ago
#29411 closed Bug (duplicate)
Pickling of a form fails after a form was used in a template
Reported by: | Torsten Bronger | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 2.0 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The following view function fails from its second invocation on:
def main(request): import django.forms as forms import pickle pickle.dump(forms.Form(), open("/dev/null", "wb")) # This fails, but not at the very first invocation. return render(request, "main.html", {"example_form": ExampleForm()})
Steps to reproduce:
django-admin startproject pickle_problem
cd pickle_problem
- Apply the attached patch with
-p1
. - Apply migrations, start testserver.
- Open the URL “/” on the testserver. You should see a bogus form with one boolean field.
- Reload the page.
What happens:
The pickling of form.Form()
fails. See the attached traceback.
I observe this problem since Django 1.11. Up to Django 1.10, it has worked fine for me.
Attachments (2)
Change History (4)
by , 6 years ago
Attachment: | testserver_output.log added |
---|
comment:1 by , 6 years ago
With the following view function, the error can be reproduced without reloading the page, which may be easier for automatic reproducing:
def main(request): pickle.dump(forms.Form(), open("/dev/null", "wb")) result = render(request, "main.html", {"example_form": ExampleForm()}) pickle.dump(forms.Form(), open("/dev/null", "wb")) return result
comment:2 by , 6 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
This looks like a duplicate of #28223. (The traceback error is the same as reported there.)
Note:
See TracTickets
for help on using tickets.
Output of Django's testserver, including the traceback.