1đź‘Ť
It’s unclear what your goal is.
“But if I just store the id and class in a tuple then I’m necessarily going back to the database every time I use any of the django objects. I’d like to be able to keep the ones I’m using in memory over the course of a page request.”
This doesn’t make sense, since a view function is a page request and you have local variables in your view function that keep your objects around until you’re finished.
Further, Django’s ORM bas a cache.
Finally, the Django-supplied session is the usual place for “in-memory objects” between requests.
You shouldn’t need to pickle anything.
0đź‘Ť
You can overload the serialization methods. But it would be simpler to put the id and class in a tuple or dict and pickle that.
- [Django]-Changing package install order in Python
- [Django]-When does Django's custom model field method to_python get anything other than an instance?
- [Django]-Using Django with MySQL for storing and looking up Large DNA Microarray Results