Monday 2:20 p.m.–2:45 p.m.

Hunting for Treasure in Django

Sebastian Vetter

Audience level:

Intermediate

Description

We all use Django because it is a framework that simplifies the development of our web apps by providing an implementation of common patterns. Additionally, it also provides a lot of helpers around these implementations that simply our lives even more. This talk will investigate the "hidden" treasures of decorators and functions in Django's core.

Abstract

Django is a comprehensive web framework that provides well-defined concepts such as request, response, middleware and view that make our lives as perfectionists with deadlines much easier. What many of us are not aware of is the rich collection of utilities and tooling around these concepts that are part of the famework. Decorators, helper functions and context managers that are used internally but can make life as a developer much easier as well.

  • Introduction (~ 2 mins)

    • A little bit about me.
    • Why am I talking about this?
  • Django's Hidden Treasures (~ 4 mins)

    • The reason for this talks.
    • What do I consider hidden treasures?
    • Which Django modules are interesting?
    • Are they documented and were do I find it?
  • Examples of hidden treasures:

    • A quick introduction of the module.
    • What's a possible use case for it?
    • How does it solve it?
    • Where is it used in the Django?

    • cached_property (~ 2 mins)

    • import_string (~ 2 mins)

    • lazy, LazyObject and lazy_property (~ 3 mins)

    • decorators module (~ 4 mins)

      • classonlymethod
      • decorator_from_middleware
      • update_wrapper and wraps (technically not Django)
    • django.views (~ 4 mins)

      • debug.cleanse_setting
      • decorators.debug.sensitive_parameters
      • decorators.debug.sensitive_post_parameters
  • Wrapping up (~ 2 mins)

    • Django documentation links.
    • Some suggestions for further investigation.