Skip to content

Instantly share code, notes, and snippets.


Tom Christie tomchristie

Block or report user

Report or block tomchristie

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:c5ed81a03808518d037e
"users": [
"organisations": [
"id": 456,
"role": "OWNER",
"editable": false,
"name": "Acme Org",
"permissions": ["SDFDS::SDFDS", "SDFDFS::SASDA"]
View gist:3fbf761fcbb9fe12a0d0
permissions = [
Permission(permission=permission, user=user, organisation=self)
for permission in ACCOUNT_PERMISSIONS
View gist:e191d680f357f104b561
View gist:7b552eace0ba5129999c
currency_serializer = CurrencySerializer(Currency.objects.all(), many=True)
service_serializer = ServiceModuleMinSerializer(ServiceModule.objects.all(), many=True)
return Response({
View gist:73a5c3a5eda6325e2f51
* REST framework 0.x - The top branch is the framework. Red branch to the left is docs. Bottom is example projects.
* Big pause - This'd be when my first son was born. Had my hands full.
* You can see when version 2.0 arrives as there's a flurry of activity - the code examples disappear and the docs get loads of work instead.
* During 2.x the tests move out of the package itself, causing another branch off of the center.
* You can tell when version 3.0 arrives, as a whole bunch of blue sponsor images appear in the red docs branch.
* The templated HTML rendering results in three sets of small purple branchs in the main framework, corresponding to vertical, horizontal and inline style templates.
* The big white flower is all the supported languages as we add internationalization to the project.
class InvoiceList(ManyRelatedField):
def __init__(self):
child = InvoiceSerializer()
super(InvoiceList, self).__init__()
def to_representation(self, iterable):
request = self.parent.context['request']
return [
for value in iterable.filter(user=request.user)
tomchristie /
Created Sep 20, 2011
JSONRenderer that doesn't force ascii
class UnicodeJSONRenderer(BaseRenderer):
Renderer which serializes to JSON
media_type = 'application/json'
format = 'json'
def render(self, obj=None, media_type=None):
tomchristie /
Created Sep 21, 2011
Better API on DocumentingTemplateRenderer for escaping content.
class DocumentingTemplateRenderer(BaseRenderer):
escape_binary = True
def _escape_binary(content):
if self.escape_binary and not all(char in string.printable for char in content):
return '[%d bytes of binary content]' % len(content)
return content
tomchristie / gist:1372740
Created Nov 17, 2011
Don't attempt to connect to the Selenium server at import; Wait until the first test is run.
View gist:1372740
class SeleniumTestCase(LiveServerTestCase):
_selenium_server_running = None
def selenium_server_running(self):
Determine if we can connect to the Selenium RC server.
Only evaluated once for performance reasons.
You can’t perform that action at this time.