Books: 2019-04

April was a travelling month: I spent all of five days at home, and the rest of the time I moved between Berlin, Copenhagen, Vienna, and Berlin again. While this was fairly stressful, it gave me plenty of time to read on the various trains and ferries I travelled on.


A @context decorator for Django

Even the happiest Django developers with the most ardent love of class-based views can get tired of writing super().get_context_data(**kwargs), only to add a couple of already-implemented properties or methods to the template context.

django-context-decorator provides, as the name may hint at, a decorator named @context. You can wrap it around both methods and properties, including Django's cached property, and it will add the property's value or the method's return value to your template context: