djangosnippets.org: Latest snippets posted by danielsokolowskihttps://djangosnippets.org/users/danielsokolowski/2011-11-09T11:59:17.264211-06:00danielsokolowskiDjango template tag to hash/map a value to a unique web color.
2011-11-09T11:59:17.264211-06:00danielsokolowskihttps://djangosnippets.org/snippets/2597/<p>Just a quick and dirty solution I needed to uniquely color code entries in a selection form list. </p>
<p>It uses the hashlib to generate it's coloring. </p>
Freely redistributableUpdated: GeoJSON Serializer for GeoDjango (gis)
2011-11-09T11:36:21.375773-06:00danielsokolowskihttps://djangosnippets.org/snippets/2596/<p>Unfortunately the built in Django JSON serialzer encodes GeoDjango GeometyrField as WKT text. This snippet extends django's serializer and adds support for GEOJson format.</p>
<p>Built in JSON serializer output:</p>
<pre><code>[{"pk": 1, ... "geopoint": "POINT (-76.5060419999999937 44.2337040000000030)" ... }]
</code></pre>
<p>GeoJSON serializer ouput:</p>
<pre><code>[{"pk": 1, ... "geopoint": {"type": "Point",
"coordinates": [-76.503296000000006, 44.230956999999997], …</code></pre>
Freely redistributableGeneric view mixing that allows output to JSON, HTML, HTML SNIPPETS
2011-08-04T16:00:12.660425-05:00danielsokolowskihttps://djangosnippets.org/snippets/2504/<p>Adding this mixing to your existing class based views allows for outputting of queries into any registered serialzier format -- very handy for dynamic JS based GUI on the JSON format.</p>
<p>This generic view mixing was created on our last project which required a fancy JS based user experience and …</p>
Freely redistributableGeoJSON Serializer for GeoDjango (gis)
2011-05-12T11:32:00.005116-05:00danielsokolowskihttps://djangosnippets.org/snippets/2434/<p><strong>Please use the updated version http://djangosnippets.org/snippets/2596/</strong></p>
<p>Unfortunately the built in Django JSON serialzer encodes GeoDjango GeometyrField as simple text. This snippet extends django's serializer and adds support for GeoJson format.</p>
<p>Built in JSON serializer output:</p>
<pre><code>[{"pk": 1, ... "geopoint": "POINT (-76.5060419999999937 44.2337040000000030)" ... }]
</code></pre>
<p>GeoJSON serializer ouput:</p>
<pre><code>[{"pk": 1, ... …</code></pre>
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 redistributable