DjangoCon EU 2015

Cardiff_City_Hall_cropped.jpg

Last week we headed over to Cardiff to attend and support our first DjangoCon Europe. Although the Welsh capital met us with stormy showers and blustery winds, the Django community proved to be warm and very welcoming. In this post I’m going to cover DjangoCon EU’s efforts around social responsibility and report on the talks \[…\]

Introduction

Last week we headed over to Cardiff to attend and support our first DjangoCon Europe. Although the Welsh capital met us with stormy showers and blustery winds, the Django community proved to be warm and very welcoming.

In this post I’m going to cover DjangoCon EU’s efforts around social responsibility and report on the talks I attended including David Gouldin on the Polyglot Web, Kat Stevens and her Full Stack Octopus, Benjamin Wohlwend talking about giving your pony wings and last – but certainly not least – Aaron Bassett on Effortless real time apps in Django

Social responsibility

Social responsibility was right in the centre of DjangoCon. The organisers were very strict with diners’ RSVPs to avoid any food waste. There were no plastic water bottles, but each conference attendee was supplied with a reusable aluminium one and there were plenty of water coolers around the venue to refill them. They even put together a guide on alternative means to air travel to reduce the environmental impact! Moreover, I think DjangoCon was probably the first conference I had ever been to that provided a creche, so parents with small children could attend without the hassle of having to find a nanny for a few days. Cardiff University provided a free wellbeing service. Anybody at the conference could receive physical or emotional wellbeing advice on a walk-in basis. Pretty impressive.

Now, the talks. Once again, the organisers have been very inclusive and ran sessions for different levels of experience on different days. The was only one track, but the program was extensive. Unfortunately I only got to go to a few talks, but I’m glad I did. Some takeouts to follow.

David Gouldin – Polyglot web

David Gouldin, a ‘djangonaut’ based in San Francisco, gave a talk on Django’s role in the polyglot web. It was interesting to find out that although Django is not a CMS, it had originally been built as one. In the 10 years of Django existence the web has changed dramatically, but according to David, Django is still in a pretty good place. Among the strong points David mentioned Django REST framework, which makes it extremely easy to build good APIs, and the effortlessness of using Celery.

But, as with any other framework, there are also weaker sides to Django, such as long-running connections and JS client integration. Another issue mentioned by David was C10k. David’s advice was to take a mix-and-match approach when choosing your stack and use the right tool for the right job, a “polyglot” approach. He gave an example of using Django and Socket.IO with Redis and Celery. David didn’t cover this, but of course if you’d rather save your polyglotisms for elsewhere in your app, you can offload the real-time layer to Pusher!

Kat Stevens – The full stack octopus

I also went to see Kat Stevens‘ talk called “The full stack octopus”. Kat is the only web developer in a wine company (the result of Kat’s love of the web and wine) and has to constantly wear many different hats, dealing with planning, sysadmin, bug fixing etc. When Kat started her job, she was faced with a very old .NET legacy site. Having the freedom of choice to pick any tech she wanted, Kat went with Django, which is still her favourite part of the stack. Kat discussed the main advantages and drawbacks of her role. On a plus side, she only has to merge code with herself and can do everything to her preferences, choosing libraries and APIs. Small fixes can be deployed almost instantly without the need for a complex ticketing system. On the other hand, there’s a lack of technical feedback and more in-depth knowledge, so she often ends up “re-inventing the wheel”. Kat admitted she’s not an expert in any particular area, but her determination to learn and improve drives her forward.

Benjamin Wohlwend – Give your pony wings

Benjamin Wohlwend’s talk “Give your pony wings” was among my favourites (not just because of the cutest title). Benjamin discussed solutions for dealing with performance issues. To find performance problems he normally uses django-debug-toolbar, which lists the number of queries – a common performance problem, and django-devserver, which is a runserver replacement. Django’s select_related() and prefetch_related() can help reduce the number of queries. Select_related() allows you to immediately grab related objects in one big query. Prefetch_related() is similar but is better for dealing with many-to-many fields and reverse foreign keys.

Benjamin also discussed caching for better performance. However, cache validation can be hard and can make your code harder to test. He suggested to use it only when it’s really needed. A straight-forward way would be to use @cache_page decorator; template caching with {% cache %} and ORM caching with johny-cache or django-cache-machine. To learn more about the subject Benjamin recommended the “High Performance Django” book by Peter Baumgartner and Yann Malet.

Aaron Bassett – Effortless real-time apps in Django

IMG_20150602_164637

Aaron Bassett gave a talk on building realtime applications with Django using a Django package called Swamp Dragon, which consists of Redis, Tornado and Django. Aaron included a step-by-step example of building a simple TODO app. He also showed how you can integrate Pusher to simplify the architecture.

swamp-dragon-pusher-eu-2015.jpeg

Above you can see two of Aaron’s slides. Firstly using Swamp Dragon, Redis and Tornado to power your real-time Django app. Then removing Redis and Tornado completely, using Swamp Dragon purely for object serialization, and utilitizing Pusher’s real-time infrastructure to maintain all the WebSocket connections and deliver all the messages. Of course, you could remove Swamp Dragon all together if you wanted to, but Aaron was covering a migration process and liked the way it handled serialization.

You can find Aaron’s demo code here. He also showed how to add realtime notifications with Django-Pusherable. You can read more about it in his django-pusherable blog post.

We had a brilliant time and lots of interesting conversations at DjangoCon. It was a real pleasure to be a part of it and we’re looking forward to more Django events in the future.