djangosnippets.org: Latest snippets tagged with 'pickle'https://djangosnippets.org/tags/pickle/2012-01-10T16:21:06.401532-06:00JSON instead of pickle for memcached
2012-01-10T16:21:06.401532-06:00divermanhttps://djangosnippets.org/snippets/2642/<p>Standard memcache client uses pickle as a serialization format. It can be handy to use json, especially when another component (e.g. backend) doesn't know pickle, but json yes.</p>
Freely redistributableNon-pickling locmem (in-process memory) cache backend
2011-03-18T02:52:10.319667-05:00akaiholahttps://djangosnippets.org/snippets/2396/<p>You can use this cache backend to cache data in-process and avoid the overhead of pickling. Make absolutely sure you don't modify any data you've stored to or retrieved from the cache. Make deep copies instead if necessary.</p>
<p>The backend is basically identical to Django's stock locmem cache (as of …</p>
Freely redistributableImproved Pickled Object Field (Fixed for Django 1.2)
2011-02-02T11:56:43.483263-06:00danielsokolowskihttps://djangosnippets.org/snippets/2346/<p>Small changes to <a href="http://djangosnippets.org/snippets/1694/">Snippet 1694</a> to that QueryAPI works for django 1.2 and higher.
</p>
<p>Changes:
</p>
<ul>
<li>
Replaced <code>get_db_prep_value</code> with <code>get_prep_value</code>.
</li>
<li>
Replaced <code>get_db_prep_lookup</code> with modified <code>get_prep_lookup</code>.
</li>
</ul>
Freely redistributableImproved Pickled Object Field
2009-08-20T13:00:49.020099-05:00taavi223https://djangosnippets.org/snippets/1694/<p><a href="http://www.djangosnippets.org/snippets/513/">Based on snippet #513 by obeattie.</a></p>
<p><strong>Update 10/10/09:</strong> <a href="http://github.com/shrubberysoft/django-picklefield">Further development is now occurring on GitHub, thanks to Shrubbery Software.</a></p>
<p>Incredibly useful for storing just about anything in the database (provided it is Pickle-able, of course) when there isn't a 'proper' field for the job.</p>
<p><code>PickledObjectField</code> is database-agnostic, and should work …</p>
Freely redistributablePickled Object Field
2007-12-16T04:43:01.280925-06:00obeattiehttps://djangosnippets.org/snippets/513/<p><em>Incredibly useful for storing just about anything in the database (provided it is Pickle-able, of course) when there isn't a 'proper' field for the job:</em></p>
<p>A field which can store any pickleable object in the database. It is database-agnostic, and should work with any database backend you can throw at …</p>
Freely redistributableDatabase migration and dump/load script
2007-04-10T13:56:38.196937-05:00akaiholahttps://djangosnippets.org/snippets/167/<p>I once needed to convert a Django project from PostgreSQL to SQLite. At that time I was either unaware of manage.py dumpdata/loaddata or it they didn't yet exist. I asked for advice on the #django IRC channel where ubernostrum came up with this plan:
</p>
<pre><code>simple process:
1) Select everything.
2) …</code></pre>
Freely redistributable