Skip to content

Instantly share code, notes, and snippets.

@kevin-brown
kevin-brown / filter_queryset.py
Last active August 7, 2017 15:25
Demonstration of how you can dynamically filter the queryset containing the objects which are allowed to be set on a field.
class FooSerializer(serializers.ModelSerializer):
# Any subclass of a RelatedField, which would normally have a queryset
bar = serializers.HyperlinkedRelatedField(
queryset=Bar.objects.none(), # don't unintentionally expose information
)
def __init__(self, *args, **kwargs):
# Make sure that self.fields is populated
super().__init__(*args, **kwargs)
export const GoogleApi = function(opts) {
opts = opts || {}
const apiKey = opts.apiKey;
const libraries = opts.libraries || [];
const client = opts.client;
const URL = 'https://maps.googleapis.com/maps/api/js';
const googleVersion = '3.22';
let script = null;
@deanmcpherson
deanmcpherson / alignment.css
Created June 16, 2016 07:54
Text alignment -> draftjs workaround
.alignment--left {
.public-DraftStyleDefault-block {
text-align; left;
}
}
.alignment--center {
.public-DraftStyleDefault-block {
text-align; center;
}
}