Opened 17 years ago
Last modified 14 years ago
#10865 closed
Unable to pickle Queryset — at Version 2
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | Uncategorized | Version: | dev |
| Severity: | 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 (last modified by )
I am getting an error while trying this code. I am using memcached as my backend. It looks like it isn't able to correctly pickle the queryset. This article makes me think it should be able to pickle them... http://docs.djangoproject.com/en/dev/ref/models/querysets/#pickling-querysets
>>> places = Place.objects.all()
>>> cache.set("places", pickle.dumps(places))
>>> c = cache.get("places")
>>> pickle.loads(c)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/lib/python2.6/pickle.py", line 1374, in loads
return Unpickler(file).load()
File "/usr/lib/python2.6/pickle.py", line 858, in load
dispatch[key](self)
File "/usr/lib/python2.6/pickle.py", line 1090, in load_global
klass = self.find_class(module, name)
File "/usr/lib/python2.6/pickle.py", line 1124, in find_class
__import__(module)
TypeError: __import__() argument 1 must be string without null bytes, not str
Change History (3)
comment:1 by , 17 years ago
comment:2 by , 17 years ago
| Description: | modified (diff) |
|---|
Please use preview. Also can you provide your models so we can reproduce.
by , 17 years ago
| Attachment: | pickle_test.tar.gz added |
|---|
Note:
See TracTickets
for help on using tickets.
The formatting got messed up on my last post. Hopefully this will look better.
>>> places = Place.objects.all() >>> cache.set("places", pickle.dumps(places)) >>> c = cache.get("places") >>> pickle.loads(c) Traceback (most recent call last): File "<console>", line 1, in <module> File "/usr/lib/python2.6/pickle.py", line 1374, in loads return Unpickler(file).load() File "/usr/lib/python2.6/pickle.py", line 858, in load dispatch[key](self) File "/usr/lib/python2.6/pickle.py", line 1090, in load_global klass = self.find_class(module, name) File "/usr/lib/python2.6/pickle.py", line 1124, in find_class __import__(module) TypeError: __import__() argument 1 must be string without null bytes, not str