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 foo.html
<form method="POST">
{% csrf_token %}
{% bootstrap_form form %}
<button type="submit" class="btn btn-primary">Submit</button>
import tablib
coalition_parties = ('Lab', 'LD', 'Green')
factor = 1.0
data = tablib.Dataset()
data.csv = open('../Desktop/hocl-ge2015-results-full.csv', 'r').read()
View REST framework
  • Schema & hypermedia support.
  • Better API documentation options.
  • Client libraries for range of languages.
  • Mature authentication defaults.
  • Faster time-to-production.
  • Performance & monitoring.
  • Debugging tools.
  • Realtime API support & documentation.
  • Highlighting & supporting third party packages.
  • Beta release versions & reducing bus factor.
response = requests.get('')
content_type = response.headers.get('content-type')
codec = coreapi.negotiate_decoder(content_type, decoders=decoders)
doc = codec.load(response.content)
doc = Document(
'notes': [
'description': 'Write the talk',
class CountryCodeField(serializers.Field):
codes = {'US': 45, 'AU': 12}
def to_internal_value(self, value):
# make sure it is a string
if type(value) is not str:
raise ValidationError('`value` must be a string, you sent type %s' % type(value))
# check length
if len(value) != 2:

How to communicate

Exploring the fundamentals of how we build networked application interfaces.

What problems are we running into building Web APIs today? How can we best take advantage of Django's upcoming channels work to build realtime systems? What are Django's strengths in the changing API landscape, and how can it stay relevant?

  • REST - Taking a look at the pain points.
  • GraphQL - Why it exists, and what it could mean for the future.
  • Realtime - How we can build realtime interfaces in a more structured way.
  • Hypermedia - Why it hasn't yet lived up to its promises, and how it still might.
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)
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.
def _get_displayed_page_numbers(current, final):
This utility function determines a list of page numbers to display, based
on the same pagination display style that GitHub use in their issue list pages.
This gives us a nice contextually relevant set of page numbers to display.
For example:
current=14, final=16 -> [1, 2, None, 12, 13, 14, 15, 16]
current=2, final=16 -> [1, 2, 3, 4, 5, None, 15, 16]
You can’t perform that action at this time.