Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<!--
Load the MapPaint plugin.
@ebrelsford
ebrelsford / forms.py
Created March 28, 2013 13:56
A modification of Django's admin widget RelatedFieldWidgetWrapper, which adds the handy + to select boxes when picking a related model. This one doesn't assume the user's picking a related model instance--it simply lets the user pick a model instance or add a new one if needed. This is useful on forms (such as the example in forms.py) where you …
"""
An example form using AddAnotherWidgetWrapper.
"""
from django import forms
from .models import Owner
from .widgets import AddAnotherWidgetWrapper
class PickOwnerForm(forms.Form):
@ebrelsford
ebrelsford / gist:5592416
Created May 16, 2013 15:07
Get clusters from a GeoDjango model that could be used in a heatmap (eg, using Heatmap.js), including potentially dynamic filters on the model.
from django.db import connection, DEFAULT_DB_ALIAS
num_clusters = 6
queryset = model.objects.filter() # Your filters here
queryset = queryset.filter(centroid__isnull=False).only('centroid')
# Get the query for
sql_model_query, params = queryset.query.get_compiler(DEFAULT_DB_ALIAS).as_sql()
@ebrelsford
ebrelsford / map.geojson
Created December 19, 2013 16:28
A geojson file uploaded directly to Gist
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.