7👍
This may not be the case for everyone, but I was using Ipython notebook and having a similar issue pickling my own class.
The problem turned out to be from a reload call
from dir.my_module import my_class
reload(dir.my_module)
Removing the reload call and then re-running the import and the cell where the instance of that object was created then allowed it to be pickled.
1👍
not so elegant but perhaps it works:
add the directory of the myfile
-module to os.sys.path
and use only import myfile
in each module where you use myfile
. (remove any from segment.segmentengine.models.segment import
, anywhere in your project)
- [Django]-How to avoid AppConfig.ready() method running twice in Django
- [Django]-ImportError: No module named 'django.core.urlresolvers'
- [Django]-Django: using <select multiple> and POST
0👍
According to this doc, pickling a QuerySet should be not a problem. Thus, the problem should come from other place.
Since you mentined:
EDIT2: I had a typo in the error I displayed above — it was models.QuerySet, not models.mymodel.QuerySet that it was complaining about. There is another nuance here, which is that my models file is broken out into multiple modules, so the error is ACTUALLY:
- The second error message you provided look like the same as previous one, is that what you mean?
- The error message you provided looks weird. Since you are pickling “queryset.query”, the error should related to the django.db.models.sql.Query class instead of the QuerySet class.
Some modules or classes may have the same name. They will override each other then cause this kind of issue. To make thing easier, I will recommend you to use “import ooo.xxx” instead of “from ooo import *”.
- [Django]-What's the best way to handle Django's objects.get?
- [Django]-Get name of primary field of Django model
- [Django]-Testing custom admin actions in django
- [Django]-How to make Django QuerySet bulk delete() more efficient
- [Django]-How do I call a Django function on button click?
- [Django]-How to get request object in django unit testing?