Tying up a loose end - How class-based emails will save your day
06-07, 11:45–12:15 (Europe/Madrid), Auditorium

Improve your codebase and developer experience by using the novel class-based emails from “django-pony-express” – shipped with a test-suite – to finally have a DRY email setup and save the day!


Yes, it's possible to send emails from your Django application. And in most business cases, it's required. But is it fun? Is it DRY? Where do my variables for my base template go? Does it feel like reinventing the wheel when implementing some level of abstraction? And how the heck am I supposed to write a proper unit test? Well, in most cases, most of the Djangonauts I know including myself would go for a "no" or at least “dunno”.

That’s why I implemented "django-pony-express" to tackle those problems. Like existing djangoesque patterns and therefore easy to grasp, you'll define your emails in a neat class instead of a bunch of similar looking functions. The presented approach will take care of having duplicated templates for the plain-text and HTML parts, variables needed for your base template and much more.
But the best part: It ships with a test suite which transforms the Django test mailbox to a QuerySet-like object which can be worked with without having to have a diploma. Furthermore, it provides a best-practice to unit-test your emails to finally enable every developer in the team to test even those parts of your code.

I’m going to present the package “django-pony-express” which delivers a class-based abstraction layer like the Django Class-based views.

Emails are a crucial part of many business applications. Having worked on many (>15) different projects in various industry sectors over the last 11 years, I realised that implementing clean, reusable code for your emails is always a challenge. The whole project is neat and DRY – except your email setup and of course the duplicated templates for the plain-text and HTML part.
Here’s what I want to talk about:

• Motivation how a professional email setup looks like and what issues you must tackle to achieve it.

• Introducing the solution and its benefits and tweaks.

• Presenting the test suite and demonstrate the best practices to write unittests with it.

• Critical review and outlook to the future.

As a take-away, every attendee should have gotten an idea what’s required to create a professional email setup, why the package will help them achieve that (in less time) and how to write neat unit-tests for your mails.

Video: https://youtu.be/Be0qOagM6xs


Topics

Architecture, Testing

Audience Level

Intermediate

My name is Ronny, I'm born Austrian and grew up, studied and started working with Django in Cologne, Germany.

I studied Business Information Systems at the University of Cologne I tried hard to avoid getting a regular consulting job after I got my diploma. Ending up (and staying) at Ambient Digital in 2012 as a web developer, I've done and seen many things but Django was always an essential part of all of it.

My first Djangocon experience was in Heidelberg in 2018 where I expected... something different. I was honestly astonished that it's possible to sit and listen to talks all day and not getting bored. #notuni Ever since, I attended all cons, either in person or remotly (due to the pandemic).